I'm getting an error when trying to link an object file:
$ g++ -o intro intro.o -L -Wl,-rpath-link -lnotes -lm -lnsl -lpthread -lc -lresolv -ldl
/usr/bin/ld: cannot find -lnotes
collect2: ld returned 1 exit status
However, the library seems to be there (in fact, I put it there by including /opt/ibm/lotus/notes
in a file in /etc/ld.so.conf.d/
and running ldconfig
):
$ ldconfig --print-cache | grep libnotes
361: libnoteswc.so (libc6) => /opt/ibm/lotus/notes/libnoteswc.so
362: libnotes.so (libc6) => /opt/ibm/lotus/notes/libnotes.so
Why does the linking fail and how can I bring the linker to use these shared objects?
GCC does not specify a runpath so that the dynamic linker can find dynamic libraries at runtime...Yet another option, that works on a few platforms, is to hard-code the full pathname of the library into its soname. This can only be accomplished by modifying the appropriate .ml file within libstdc++/config (and also libg++/config, if you are building libg++), so that $(libdir)/ appears just before the library name in -soname or -h options.
http://gcc.gnu.org/faq.html#rpath
Try with the -L flag for ld. An example of one of my Makefile :
CFLAGS=-c -Wall -O2 \
-I../libs/libs-x86/include
LDFLAGS=-lupnp \
-L ../libs/libs-x86/lib
I think libraries described in "/etc/ld.so.conf.d/" are for runtime only ... Hope this helps !
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With