开发者

how does a linker functions?

开发者 https://www.devze.com 2023-03-10 09:40 出处:网络
In static linking, how does the linker knows which library file to link the us开发者_StackOverflower\'s compiled object code against? I mean the header only contains the function protoytpes that may b

In static linking, how does the linker knows which library file to link the us开发者_StackOverflower's compiled object code against? I mean the header only contains the function protoytpes that may be used in the source code, not the library file name.. isn't it?


That's why you provide the linker with a list of libraries to link against!

e.g. for GCC, you might do something like:

gcc my_prog.o -lm -lpthread -o my_prog

Here, the -l flag is used to tell the linker to link against libm and libpthread.


It gets a list of libraries from the command line. The specifics will depend on the OS and the compiler.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号