I found that when using -rpath, the -L flag should be set. For example:
gcc -o test test.o -L. -lmylib -Wl,-rpath=.
Why is the -L flag needed? What information is more than information from h files needed at compile time?
If I remove -L. I get the following message:
gcc -o test test.o -lmylib -Wl,-rpath=. /usr/bin/ld: cannot find -lmyLib
However, it is normal to remove both flags. Like this:
gcc -o test test.o -lmylib
If libmyLib can be found in / usr / lib, that is. Why not -L needed now?
This is the following question: stack overflow
gcc linker shared-libraries
Fredrik Johansson Jan 22 '15 at 18:29 2015-01-22 18:29
source share