Why is -L needed when -rpath is used?
I find that the -L flag must be given when using -rpath. For instance: gcc -o test test.o -L. -lmylib -Wl,-rpath=. Why is the -L flag needed? What information more than the information from the h-files are 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 It's perfectly ok to remove both flags, though. Like this: gcc -o test test.o -lmylib Provided that libmyLib can be found in /usr/lib, that is. Why isn't -L needed now? This is a follow-up question to https://stackoverflow.com/a/8482308/1091780 . Even