Re: gauche-c-wrapper's cwcompile stopped working: function is not found

Jens Thiele <[email protected]> Tue, 30 Apr 2024 14:13:59 +0200
Newsgroups gmane.lisp.scheme.gauche
Message-ID <[email protected]>
Jens Thiele <[email protected]> writes:

> now I only don't know how to stop the linker from doing this
> optimization

looks like one has to pass -no-as-needed to the linker:

(bookworm-amd64-sbuild)karme@amalthea:/tmp$ cwcompile -v --ldflags="-Wl,-no-as-needed -L. -lhello" test-libhello.scm
gauche-package compile --verbose --cflags=  --cppflags=   --ldflags=-Wl,-no-as-needed -L. -lhello   --libs=  -L. -lhello  libgauche-hello libgauche-hello.stub
gcc -c    '-I/usr/local/lib/gauche-0.98/0.9.15/include'   -fPIC -o 'libgauche-hello.o' 'libgauche-hello.c'
gcc -Wl,-no-as-needed -L. -lhello   '-L/usr/local/lib/gauche-0.98/0.9.15/x86_64-pc-linux-gnu' '-L/usr/local/lib/gauche-0.98/site/x86_64-pc-linux-gnu'  -shared -o libgauche-hello.so 'libgauche-hello.o' -lgauche-0.98 -lmbedtls -lcrypt -lrt -lm  -lpthread   -L. -lhello 
(bookworm-amd64-sbuild)karme@amalthea:/tmp$ LD_LIBRARY_PATH=. ./test-libhello.scm 
#?="././test-libhello.scm":13:(add 10 32)
dlsym(add) => 0x7f5e587ac0f9
#?-    42