cacalabs / libcaca

💩 Colour ASCII Art Library
Do What The F*ck You Want To Public License
519 stars 70 forks source link

Unable to build 0.99.beta20 (common-image.c:164: undefined reference to `_caca_alloc2d') #59

Open thesamesam opened 2 years ago

thesamesam commented 2 years ago

When looking at packaging the new beta20 release for Gentoo, I hit the following error:

x86_64-pc-linux-gnu-gcc -m32 -DHAVE_CONFIG_H -I. -I/var/tmp/portage/media-libs/libcaca-0.99_beta20/work/libcaca-0.99.beta20/src -I..  -I/var/tmp/portage/media-libs/libcaca-0.99_beta20/work/libcaca-0.99.beta20 -I/var/tmp/portage/media-libs/libcaca-0.99_beta20/work/libcaca-0.99.beta20/caca -I../caca -DLIBCACA=1 -DX_DISPLAY_MISSING=1   -O2 -pipe -march=native -fdiagnostics-color=always -frecord-gcc-switches     -ggdb3 -UCACA_ENABLE_VISIBILITY -g -O2 -fno-strength-reduce -fomit-frame-pointer -Wall -Wpointer-arith -Wcast-align -Wcast-qual -Wstrict-prototypes -Wshadow -Waggregate-return -Wmissing-prototypes -Wnested-externs -Wsign-compare -fvisibility=hidden -DCACA_ENABLE_VISIBILITY -c -o cacaview-common-image.o `test -f 'common-image.c' || echo '/var/tmp/portage/media-libs/libcaca-0.99_beta20/work/libcaca-0.99.beta20/src/'`common-image.c
/var/tmp/portage/media-libs/libcaca-0.99_beta20/work/libcaca-0.99.beta20/src/common-image.c: In function ‘load_image’:
/var/tmp/portage/media-libs/libcaca-0.99_beta20/work/libcaca-0.99.beta20/src/common-image.c:164:18: warning: implicit declaration of function ‘_caca_alloc2d’ [-Wimplicit-function-declaration]
  164 |     im->pixels = _caca_alloc2d(im->w, im->h, depth);
      |                  ^~~~~~~~~~~~~
/var/tmp/portage/media-libs/libcaca-0.99_beta20/work/libcaca-0.99.beta20/src/common-image.c:164:18: warning: nested extern declaration of ‘_caca_alloc2d’ [-Wnested-externs]
/var/tmp/portage/media-libs/libcaca-0.99_beta20/work/libcaca-0.99.beta20/src/common-image.c:164:16: warning: assignment to ‘char *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
  164 |     im->pixels = _caca_alloc2d(im->w, im->h, depth);
      |                ^
/bin/sh ../libtool  --tag=CC   --mode=link x86_64-pc-linux-gnu-gcc -m32  -O2 -pipe -march=native -fdiagnostics-color=always -frecord-gcc-switches     -ggdb3 -UCACA_ENABLE_VISIBILITY -g -O2 -fno-strength-reduce -fomit-frame-pointer -Wall -Wpointer-arith -Wcast-align -Wcast-qual -Wstrict-prototypes -Wshadow -Waggregate-return -Wmissing-prototypes -Wnested-externs -Wsign-compare -fvisibility=hidden -DCACA_ENABLE_VISIBILITY  -fuse-ld=bfd -Wl,--as-needed -o cacaview cacaview-cacaview.o cacaview-common-image.o ../caca/libcaca.la ../caca/libcaca.la -lncurses -ltinfo
libtool: link: x86_64-pc-linux-gnu-gcc -m32 -O2 -pipe -march=native -fdiagnostics-color=always -frecord-gcc-switches -ggdb3 -UCACA_ENABLE_VISIBILITY -g -O2 -fno-strength-reduce -fomit-frame-pointer -Wall -Wpointer-arith -Wcast-align -Wcast-qual -Wstrict-prototypes -Wshadow -Waggregate-return -Wmissing-prototypes -Wnested-externs -Wsign-compare -fvisibility=hidden -DCACA_ENABLE_VISIBILITY -fuse-ld=bfd -o .libs/cacaview cacaview-cacaview.o cacaview-common-image.o  -Wl,--as-needed ../caca/.libs/libcaca.so -lncursesw -lz -lncurses -ltinfo
/usr/lib/gcc/x86_64-pc-linux-gnu/11.2.0/../../../../x86_64-pc-linux-gnu/bin/ld.bfd: cacaview-common-image.o: in function `load_image':
/var/tmp/portage/media-libs/libcaca-0.99_beta20/work/libcaca-0.99.beta20/src/common-image.c:164: undefined reference to `_caca_alloc2d'
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:583: cacaview] Error 1
make[2]: Leaving directory '/var/tmp/portage/media-libs/libcaca-0.99_beta20/work/libcaca-0.99.beta20-abi_x86_32.x86/src'
make[1]: *** [Makefile:546: all-recursive] Error 1
make[1]: Leaving directory '/var/tmp/portage/media-libs/libcaca-0.99_beta20/work/libcaca-0.99.beta20-abi_x86_32.x86'
make: *** [Makefile:440: all] Error 2
 * ERROR: media-libs/libcaca-0.99_beta20::gentoo failed (compile phase):
 *   emake failed

Seems like the use of _caca_alloc2d was introduced in 96ff990d5e7cda59c73ab1d5bb77ff0c6e3b34f3 and the common-image usage is outside of the library, so might be exacerbated by 726ede64911802b1b5e638b20ce099e55ea4d3c7.

Attached the full build.log.gz.

samhocevar commented 2 years ago

Thanks for the report, I will address this soon.

Note however that cacaview is rather useless when not built with the imlib2 library. If you do not distribute that binary then it is not really a problem, of course.

shoober420 commented 2 years ago

I'm getting this same error as well when compiling current master commit https://github.com/cacalabs/libcaca/commit/f42aa68fc798db63b7b2a789ae8cf5b90b57b752. Full build log attached.

DXMPZUVRY.txt

libtool: link: x86_64-pc-linux-gnu-gcc -m32 -march=native -O3 -pipe -fno-plt -fno-common -fipa-pta -falign-functions=32 -fdevirtualize-at-ltrans -fuse-linker-plugin -floop-nest-optimize -fgraphite-identity -fexcess-precision=fast -w -flto=auto -g -O2 -fno-strength-reduce -fomit-frame-pointer -Wall -Wpointer-arith -Wcast-align -Wcast-qual -Wstrict-prototypes -Wshadow -Waggregate-return -Wmissing-prototypes -Wnested-externs -Wsign-compare -fvisibility=hidden -DCACA_ENABLE_VISIBILITY -Wl,-O1 -Wl,--as-needed -o .libs/cacadraw cacadraw.o  -L/usr/lib ../caca/.libs/libcaca.so -lncursesw -lX11 -lGL -lGLU -lglut -lz
/usr/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../x86_64-pc-linux-gnu/bin/ld: /var/tmp/portage/media-libs/libcaca-9999/temp/ccTkO2fm.ltrans0.ltrans.o: in function `load_image':
/var/tmp/portage/media-libs/libcaca-9999/work/libcaca-9999/src/common-image.c:164: undefined reference to `_caca_alloc2d'
libtool: link: x86_64-pc-linux-gnu-gcc -m32 -march=native -O3 -pipe -fno-plt -fno-common -fipa-pta -falign-functions=32 -fdevirtualize-at-ltrans -fuse-linker-plugin -floop-nest-optimize -fgraphite-identity -fexcess-precision=fast -w -flto=auto -g -O2 -fno-strength-reduce -fomit-frame-pointer -Wall -Wpointer-arith -Wcast-align -Wcast-qual -Wstrict-prototypes -Wshadow -Waggregate-return -Wmissing-prototypes -Wnested-externs -Wsign-compare -fvisibility=hidden -DCACA_ENABLE_VISIBILITY -Wl,-O1 -Wl,--as-needed -o .libs/cacademo cacademo.o  -lm -L/usr/lib ../caca/.libs/libcaca.so -lncursesw -lX11 -lGL -lGLU -lglut -lz
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:588: img2txt] Error 1
hartwork commented 1 year ago

@samhocevar any thoughts on related pull request #70?