gcc - Why is -L needed when -rpath is used? -
I think the -l flag should be given -rpath while using. For example:
GCC-O test test. O-l. -lmylib -wl, -rpath = Why is the L-L flag required? What information is needed more than information on H files at the time of compilation ?
If I delete, I get the following message:
GCC-O test test. O-lmylib -Wl, -rpath = / Usr / bin / ld: can not be found - lmyLib Although it is perfectly ok to remove both the flags, though. This way:
gcc -o test test.o -lmylib provided that libmyLib can be found in / usr / lib, that is. Now why not?
This is a follow-up question.
Even dynamic libraries require a degree of static links; Linker needs to know which symbols should be supplied by the dynamic library. The main difference is that the dynamic library provides definitions on runtime, while linking to the full static library provides definitions on time.
For this reason, -L is required to specify where to link the file, such as -l specifies the specific library . indicates the current directory.
-rpath comes into play at runtime, when the app tries to load the dynamic library. It notifies the program of an extra space to search in an attempt to load a dynamic library.
Due to the reason -l / usr / lib is not required because the linker is viewing by default (as it is a very common place to keep libraries is).
Comments
Post a Comment