what point do c libraries get linked
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.
精彩评论