开发者

what point do c libraries get linked

开发者 https://www.devze.com 2023-04-07 18:38 出处:网络
Let\'s say I redefine malloc e.g. in a memory debugging program electric fence. electric fence says that one must link the library with the gcc -g -Wall -Wstrict-prototypes -lefence test.c. So my unde

Let's say I redefine malloc e.g. in a memory debugging program electric fence. electric fence says that one must link the library with the gcc -g -Wall -Wstrict-prototypes -lefence test.c. So my understanding is that if开发者_C百科 gcc does not find the symbols in any of the libraries then it looks into the C libraries. Is this understanding correct?


Yes, and to understand what gcc is actually doing, and how does it starts the linker ld which does the real work of linking, you can pass the -v flag to gcc.


I think you are correct: the linker tries to resolve symbols using the libraries explicitly passed as parameters first, then it's looking up symbols in the C standard libraries.

0

精彩评论

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

关注公众号