Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Portage & Programming
  • Search

Trying to build IM for IUP / compilation fails

Problems with emerge or ebuilds? Have a basic programming question about C, PHP, Perl, BASH or something else?
Post Reply
Advanced search
9 posts • Page 1 of 1
Author
Message
szatox
Advocate
Advocate
Posts: 3858
Joined: Tue Aug 27, 2013 12:35 pm

Trying to build IM for IUP / compilation fails

  • Quote

Post by szatox » Wed Dec 03, 2025 8:39 pm

I want to build IUP. According to https://iup.sourceforge.net/ (Guide -> Building in Linux ) I should start with IM as its dependency, so here's an IM ebuild draft (does partial checkout from project's svn)
https://bpa.st/SWKQ

and this is the complete build log:
https://paste.gentoo.zip/hpSEPX1G

and the snippet I find most likely to be relevant:

Code: Select all

# grep -iC 3 error: /tmp/portage/dev-libs/im-3.15/temp/build.log 
Tecmake: compiling jas_stream.c ...
gcc -c  -Wall -O2 -m64 -fPIC -Ilibjasper2 -I../include    -DEXCLUDE_JPG_SUPPORT -DEXCLUDE_MIF_SUPPORT -DEXCLUDE_PNM_SUPPORT -DEXCLUDE_BMP_SUPPORT -DEXCLUDE_PGX_SUPPORT -DEXCLUDE_RAS_SUPPORT -DEXCLUDE_TIFF_SUPPORT -DJAS_GEO_OMIT_PRINTING_CODE -DJAS_BINFILE -DJASPER_2 -DHAVE_UNISTD_H -DJAS_TYPES -DTEC_UNAME=Linux617_64 -DTEC_SYSNAME=Linux -DLinux=6.17 -DTEC_LITTLEENDIAN -DTEC_64 -DFUNCPROTO=15 -DNDEBUG -o ../obj/im_jp2/Linux617_64/jas_stream.o libjasper2/base/jas_stream.c
libjasper2/base/jas_stream.c: In function ‘jas_stream_tmpfile’:
libjasper2/base/jas_stream.c:535:13: error: implicit declaration of function ‘unlink’ [-Wimplicit-function-declaration]
  535 |         if (unlink(obj->pathname)) {
      |             ^~~~~~
libjasper2/base/jas_stream.c: In function ‘file_read’:
libjasper2/base/jas_stream.c:1334:16: error: implicit declaration of function ‘read’; did you mean ‘fread’? [-Wimplicit-function-declaration]
 1334 |         return read(fileobj->fd, buf, cnt);
      |                ^~~~
      |                fread
libjasper2/base/jas_stream.c: In function ‘file_write’:
libjasper2/base/jas_stream.c:1343:16: error: implicit declaration of function ‘write’; did you mean ‘fwrite’? [-Wimplicit-function-declaration]
 1343 |         return write(fileobj->fd, buf, cnt);
      |                ^~~~~
      |                fwrite
libjasper2/base/jas_stream.c: In function ‘file_seek’:
libjasper2/base/jas_stream.c:1352:16: error: implicit declaration of function ‘lseek’; did you mean ‘fseek’? [-Wimplicit-function-declaration]
 1352 |         return lseek(fileobj->fd, offset, origin);
      |                ^~~~~
      |                fseek
libjasper2/base/jas_stream.c: In function ‘file_close’:
libjasper2/base/jas_stream.c:1361:15: error: implicit declaration of function ‘close’; did you mean ‘pclose’? [-Wimplicit-function-declaration]
 1361 |         ret = close(fileobj->fd);
      |               ^~~~~
      |               pclose
--
make[2]: *** [../tecmake.mak:1771: ../obj/im_jp2/Linux617_64/jas_stream.o] Error 1
make[1]: *** [Makefile:14: im_jp2] Error 2
make: *** [Makefile:4: do_all] Error 2
 * ERROR: dev-libs/im-3.15::local failed (compile phase):
 *   emake failed
 * 
 * If you need support, post the output of `emerge --info '=dev-libs/im-3.15::local'`,
This code is a bit old, but it is supposed to be working. Can someone translate it from gcc to English for me?
Make Pipewire a system service
Top
GDH-gentoo
Advocate
Advocate
User avatar
Posts: 2115
Joined: Sat Jul 20, 2019 7:02 pm
Location: South America

  • Quote

Post by GDH-gentoo » Thu Dec 04, 2025 12:19 am

Looks like libjasper2/base/jas_stream.c is calling functions that are not declared, which recent compilers no longer accept. Probably fixable by patching the source file to include some missing header, likely <unistd.h>.
Ionen wrote:As a packager I just don't want things to get messier with weird build systems and multiple toolchains requirements though :)
Top
szatox
Advocate
Advocate
Posts: 3858
Joined: Tue Aug 27, 2013 12:35 pm

  • Quote

Post by szatox » Thu Dec 04, 2025 10:23 am

Thanks for the hint. I had a look at the sources, and it seems this particular include is deliberately disabled via an ifdef. Weird.

Before I go fixing the code (or finding out it's above my pay-grade), I figured I'd just build it with gcc 14 instead just to see if it fits my purpose.
I tried to override compiler inside my ebuild, but the only thing that actually worked was calling make directly (without emake).
What is the correct syntax for that? (I know, the docs say "don't do that", but I have my reasons, k? :lol: )
The weirdest part was when I dug up EXTRA_EMAKE variable, set it to "CC=gcc-14 CXX=g++-14" and then saw emerge invoke cc1 from gcc-14 and cc1plus from gcc-15. Like, why does CXX part specifically get ignored?


Well, I guess calling make directly is good enough for now. Asking mostly out of curiosity at this point. Will get back to fixing the code once I determine it's worth it.
Make Pipewire a system service
Top
GDH-gentoo
Advocate
Advocate
User avatar
Posts: 2115
Joined: Sat Jul 20, 2019 7:02 pm
Location: South America

  • Quote

Post by GDH-gentoo » Fri Dec 05, 2025 1:43 pm

(Before the uploaded files expire)
szatox wrote:I want to build IUP. According to https://iup.sourceforge.net/ (Guide -> Building in Linux ) I should start with IM as its dependency, so here's an IM ebuild draft (does partial checkout from project's svn)
https://bpa.st/SWKQ

and this is the complete build log:
https://paste.gentoo.zip/hpSEPX1G
I see this indeed:

src/libjasper2/base/jas_stream.c

Code: Select all

/* The configuration header file should be included first. */
#include "jasper/jas_config.h"
// ...
#if defined(JAS_HAVE_UNISTD_H)
#include <unistd.h>
#endif
src/libjasper2 /jasper/jas_config.h

Code: Select all

#undef JAS_HAVE_UNISTD_H
So, <unistd.h> would be included if JAS_HAVE_UNISTD_H is defined as a macro name. Judging by the name, it looks like it should be defined by some configuration / discovery mechanism in the build system... which is already strange, because the functions that call read(), write(), etc. are unconditionally defined. Anyway:

Build log

Code: Select all

Tecmake: compiling jas_stream.c ...
gcc -c  -Wall -O2 -m64 -fPIC -Ilibjasper2 -I../include    -DEXCLUDE_JPG_SUPPORT -DEXCLUDE_MIF_SUPPORT -DEXCLUDE_PNM_SUPPORT -DEXCLUDE_BMP_SUPPORT -DEXCLUDE_PGX_SUPPORT -DEXCLUDE_RAS_SUPPORT -DEXCLUDE_TIFF_SUPPORT -DJAS_GEO_OMIT_PRINTING_CODE -DJAS_BINFILE -DJASPER_2 -DHAVE_UNISTD_H -DJAS_TYPES -DTEC_UNAME=Linux617_64 -DTEC_SYSNAME=Linux -DLinux=6.17 -DTEC_LITTLEENDIAN -DTEC_64 -DFUNCPROTO=15 -DNDEBUG -o ../obj/im_jp2/Linux617_64/jas_stream.o libjasper2/base/jas_stream.c
The invocation defines HAVE_UNISTD_H, but not JAS_HAVE_UNISTD_H, and I don't know if the build system changes the #undef directive in jasper/jas_config.h. The part responsible of setting this up correctly seems to be:

Build log

Code: Select all

Tecmake: Building Dependencies ... [ dep/im_jp2.dep.Linux617_64 ] (can be slow)

Tecmake: starting [ im_jp2:Linux617_64 ]
if [ ! -d ../obj/im_jp2/Linux617_64 ] ; then mkdir -p ../obj/im_jp2/Linux617_64 ; fi
...aaaand, I have no idea about this build system.
szatox wrote:The weirdest part was when I dug up EXTRA_EMAKE variable, set it to "CC=gcc-14 CXX=g++-14" and then saw emerge invoke cc1 from gcc-14 and cc1plus from gcc-15. Like, why does CXX part specifically get ignored?
Could be because the build system is creative and seems to use CPPC instead of CXX.

tecmake.mak

Code: Select all

#---------------------------------#
# Tools

CC       := $(TEC_TOOLCHAIN)gcc
CPPC     := $(TEC_TOOLCHAIN)g++
FF       := $(TEC_TOOLCHAIN)g77
RANLIB   := $(TEC_TOOLCHAIN)ranlib
AR       := $(TEC_TOOLCHAIN)ar
DEBUGGER := $(TEC_TOOLCHAIN)gdb
RCC      := $(TEC_TOOLCHAIN)windres
Although the offending file, jas_stream.c, is a C source file, so CC gets used.
Ionen wrote:As a packager I just don't want things to get messier with weird build systems and multiple toolchains requirements though :)
Top
Hu
Administrator
Administrator
Posts: 24403
Joined: Tue Mar 06, 2007 5:38 am

  • Quote

Post by Hu » Fri Dec 05, 2025 2:21 pm

Disclaimer: I have not looked at the source of this package. However, the pattern of having a seemingly useless #undef in a header like that is reminiscent of autoconf, which indeed would replace that with a #define if its configure test decided that the symbol should be defined.
Top
szatox
Advocate
Advocate
Posts: 3858
Joined: Tue Aug 27, 2013 12:35 pm

  • Quote

Post by szatox » Sun Dec 07, 2025 6:52 pm

Damn, the plot thickens with every line.
Project's docs say nothing about running ./configure or similar discovery scripts, it's just "put the repos under one directory OR set variables pointing to headers and go, go, GO!"
Dependency tests _could_ be invoked by make though.

Anyway, you guys gave me some ideas what to look for, so it's time to look into the sources and do some tests. Thanks.
Make Pipewire a system service
Top
szatox
Advocate
Advocate
Posts: 3858
Joined: Tue Aug 27, 2013 12:35 pm

  • Quote

Post by szatox » Wed Dec 10, 2025 7:25 pm

Alright, I did some digging through the sources, and here we are:

HAVE_UNISTD_H seen in the invocation line is added by the makefile when compiller runs on linux. A discovered flag.
There are no references to JAS_HAVE_UNISTD_H anywhere else. Kinda looks forgotten. Which is weird, considering this code is like 5 years old and has almost perfect reviews, but so be it. I decided to not thing too much about; just flip the toggle in the config and move on.
There seems to be no reason to keep trying with gcc-14, so I dropped the manual override (back to gccc-15)
Techmake is a script supposed to generate makefiles compatible with gnu make (At least one good news :lol: )


Compiler did more work than previously, but then crashed like that:

Code: Select all

~~/ snip /~~
Tecmake: librarian libim_jp2.a ...
ar r ../lib/Linux617_64/libim_jp2.a ../obj/im_jp2/Linux617_64/im_format_jp2.o ../obj/im_jp2/Linux617_64/jas_binfile.o ../obj/im_jp2/Linux617_64/jas_cm.o ../obj/im_jp2/Linux617_64/jas_icc.o .
./obj/im_jp2/Linux617_64/jas_init.o ../obj/im_jp2/Linux617_64/jas_stream.o ../obj/im_jp2/Linux617_64/jas_version.o ../obj/im_jp2/Linux617_64/jas_debug.o ../obj/im_jp2/Linux617_64/jas_iccdata
.o ../obj/im_jp2/Linux617_64/jas_malloc.o ../obj/im_jp2/Linux617_64/jas_string.o ../obj/im_jp2/Linux617_64/jas_tmr.o ../obj/im_jp2/Linux617_64/jas_getopt.o ../obj/im_jp2/Linux617_64/jas_imag
e.o ../obj/im_jp2/Linux617_64/jas_seq.o ../obj/im_jp2/Linux617_64/jas_tvp.o ../obj/im_jp2/Linux617_64/jp2_cod.o ../obj/im_jp2/Linux617_64/jp2_dec.o ../obj/im_jp2/Linux617_64/jp2_enc.o ../obj
/im_jp2/Linux617_64/jpc_bs.o ../obj/im_jp2/Linux617_64/jpc_math.o ../obj/im_jp2/Linux617_64/jpc_mqenc.o ../obj/im_jp2/Linux617_64/jpc_t1enc.o ../obj/im_jp2/Linux617_64/jpc_tagtree.o ../obj/i
m_jp2/Linux617_64/jpc_cs.o ../obj/im_jp2/Linux617_64/jpc_mct.o ../obj/im_jp2/Linux617_64/jpc_qmfb.o ../obj/im_jp2/Linux617_64/jpc_t2cod.o ../obj/im_jp2/Linux617_64/jpc_tsfb.o ../obj/im_jp2/L
inux617_64/jpc_dec.o ../obj/im_jp2/Linux617_64/jpc_mqcod.o ../obj/im_jp2/Linux617_64/jpc_t1cod.o ../obj/im_jp2/Linux617_64/jpc_t2dec.o ../obj/im_jp2/Linux617_64/jpc_util.o ../obj/im_jp2/Linu
x617_64/jpc_enc.o ../obj/im_jp2/Linux617_64/jpc_mqdec.o ../obj/im_jp2/Linux617_64/jpc_t1dec.o ../obj/im_jp2/Linux617_64/jpc_t2enc.o  
ar: creating ../lib/Linux617_64/libim_jp2.a

Tecmake: updating lib TOC libim_jp2.a ...
ranlib ../lib/Linux617_64/libim_jp2.a

Tecmake: Static Library (../lib/Linux617_64/libim_jp2.a) Done.


Tecmake: linking libim_jp2.so ...
g++ -shared -o ../lib/Linux617_64/libim_jp2.so ../obj/im_jp2/Linux617_64/im_format_jp2.o ../obj/im_jp2/Linux617_64/jas_binfile.o ../obj/im_jp2/Linux617_64/jas_cm.o ../obj/im_jp2/Linux617_64/
jas_icc.o ../obj/im_jp2/Linux617_64/jas_init.o ../obj/im_jp2/Linux617_64/jas_stream.o ../obj/im_jp2/Linux617_64/jas_version.o ../obj/im_jp2/Linux617_64/jas_debug.o ../obj/im_jp2/Linux617_64/
jas_iccdata.o ../obj/im_jp2/Linux617_64/jas_malloc.o ../obj/im_jp2/Linux617_64/jas_string.o ../obj/im_jp2/Linux617_64/jas_tmr.o ../obj/im_jp2/Linux617_64/jas_getopt.o ../obj/im_jp2/Linux617_
64/jas_image.o ../obj/im_jp2/Linux617_64/jas_seq.o ../obj/im_jp2/Linux617_64/jas_tvp.o ../obj/im_jp2/Linux617_64/jp2_cod.o ../obj/im_jp2/Linux617_64/jp2_dec.o ../obj/im_jp2/Linux617_64/jp2_e
nc.o ../obj/im_jp2/Linux617_64/jpc_bs.o ../obj/im_jp2/Linux617_64/jpc_math.o ../obj/im_jp2/Linux617_64/jpc_mqenc.o ../obj/im_jp2/Linux617_64/jpc_t1enc.o ../obj/im_jp2/Linux617_64/jpc_tagtree
.o ../obj/im_jp2/Linux617_64/jpc_cs.o ../obj/im_jp2/Linux617_64/jpc_mct.o ../obj/im_jp2/Linux617_64/jpc_qmfb.o ../obj/im_jp2/Linux617_64/jpc_t2cod.o ../obj/im_jp2/Linux617_64/jpc_tsfb.o ../o
bj/im_jp2/Linux617_64/jpc_dec.o ../obj/im_jp2/Linux617_64/jpc_mqcod.o ../obj/im_jp2/Linux617_64/jpc_t1cod.o ../obj/im_jp2/Linux617_64/jpc_t2dec.o ../obj/im_jp2/Linux617_64/jpc_util.o ../obj/
im_jp2/Linux617_64/jpc_enc.o ../obj/im_jp2/Linux617_64/jpc_mqdec.o ../obj/im_jp2/Linux617_64/jpc_t1dec.o ../obj/im_jp2/Linux617_64/jpc_t2enc.o  -L../lib/Linux617_64 -lim -lpng -lz -lm 
/usr/lib/gcc/x86_64-pc-linux-gnu/15/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -lim: No such file or directory
collect2: error: ld returned 1 exit status
make[2]: *** [../tecmake.mak:1670: ../lib/Linux617_64/libim_jp2.so] Error 1
make[1]: *** [Makefile:14: im_jp2] Error 2
make[1]: *** Waiting for unfinished jobs....

~~/ snip /~~
Tecmake: linking libim_process.so ...
g++ -shared -o ../lib/Linux617_64/libim_process.so ../obj/im_process/Linux617_64/im_arithmetic_bin.o ../obj/im_process/Linux617_64/im_morphology_gray.o ../obj/im_process/Linux617_64/im_quant
ize.o ../obj/im_process/Linux617_64/im_arithmetic_un.o ../obj/im_process/Linux617_64/im_geometric.o ../obj/im_process/Linux617_64/im_render.o ../obj/im_process/Linux617_64/im_color.o ../obj/
im_process/Linux617_64/im_histogram.o ../obj/im_process/Linux617_64/im_resize.o ../obj/im_process/Linux617_64/im_convolve.o ../obj/im_process/Linux617_64/im_houghline.o ../obj/im_process/Lin
ux617_64/im_statistics.o ../obj/im_process/Linux617_64/im_convolve_rank.o ../obj/im_process/Linux617_64/im_logic.o ../obj/im_process/Linux617_64/im_threshold.o ../obj/im_process/Linux617_64/
im_effects.o ../obj/im_process/Linux617_64/im_morphology_bin.o ../obj/im_process/Linux617_64/im_tonegamut.o ../obj/im_process/Linux617_64/im_canny.o ../obj/im_process/Linux617_64/im_distance
.o ../obj/im_process/Linux617_64/im_analyze.o ../obj/im_process/Linux617_64/im_kernel.o ../obj/im_process/Linux617_64/im_remotesens.o ../obj/im_process/Linux617_64/im_point.o ../obj/im_proce
ss/Linux617_64/im_process_counter.o ../obj/im_process/Linux617_64/im_binary.o ../obj/im_process/Linux617_64/im_convertbitmap.o ../obj/im_process/Linux617_64/im_convertcolor.o ../obj/im_proce
ss/Linux617_64/im_converttype.o  -L../lib/Linux617_64 -lim -lpng -lz -lm 
/usr/lib/gcc/x86_64-pc-linux-gnu/15/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -lim: No such file or directory
collect2: error: ld returned 1 exit status
make[2]: *** [../tecmake.mak:1670: ../lib/Linux617_64/libim_process.so] Error 1
make[1]: *** [Makefile:18: im_process] Error 2

Somehow... it attempts to use a linker directive as an input file?
Make Pipewire a system service
Top
Hu
Administrator
Administrator
Posts: 24403
Joined: Tue Mar 06, 2007 5:38 am

  • Quote

Post by Hu » Wed Dec 10, 2025 8:02 pm

You could interpret it that way, but I wouldn't quite say that. Consider:

Code: Select all

$ gcc -x c /dev/null -o /dev/null -lim
/usr/lib/gcc/x86_64-pc-linux-gnu/14/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -lim: No such file or directory
collect2: error: ld returned 1 exit status
The linker treats -lFOO as a request to link to libFOO.so (or various other names, depending on shared versus static). If none of those can be found, you get this error message. So I think the issue is that you are expected to have a libim.a or libim.so available, and neither can be found. As to why you have neither of those, I cannot say. Perhaps the build's dependencies are incompletely specified.
Top
szatox
Advocate
Advocate
Posts: 3858
Joined: Tue Aug 27, 2013 12:35 pm

  • Quote

Post by szatox » Wed Dec 10, 2025 11:10 pm

I see. Turns out it's a race condition.
I looked into the directory where those libs should go, and I noticed that timestamps on very much existing files were slightly off. Building it with with MAKEOPTS="-j1" works. Multithreaded build reliably fails, trying to link against a library which is still being compiled itself.
Make Pipewire a system service
Top
Post Reply

9 posts • Page 1 of 1

Return to “Portage & Programming”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic