Linking in C using gcc
If I wanted to link the following objects and libraries,
p.o → libx.a → p.o
Where a → b denotes th开发者_运维问答at b defines a symbol that is referenced by a.
Would
UNIX% gcc p.o libx.a
be enough in the command line or do I need to do something like:
UNIX% gcc p.o libx.a p.o
Thanks.
For the record: if you're using the GNU linker, the perfect solution for you is:
gcc -Wl,--start-group p.o libx.a -Wl,--end-group
精彩评论