开发者

how does a linker functions?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜