开发者

Linking in C using gcc

开发者 https://www.devze.com 2023-01-17 19:54 出处:网络
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.

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

0

精彩评论

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