Hi I'm a beginner in C and Linking, I was reading a book that has a question in linking with static library:
Let a and b denote object modules or static libraries in the current directory, and let a→b denote that a depends on b, in the sense that b defines a symbol that is referenced by a. For each of the following scenarios, show the minimal command line (i.e., one with the least number of object file and library arguments) that will allow the static linker to resolve all symbol references:
p.o → libx.a → liby.a and liby.a → libx.a →p.o
and the answer given by the book is:
gcc p.o libx.a liby.a libx.a
I'm confused, shouldn't the answer be :
gcc p.o libx.a liby.a libx.a p.o
otherwise how the undefined symbol in libx.a
resolved by p.o
?
转载于:https://stackoverflow.com/questions/53149260/linking-with-static-library-in-c