开发者

Does the sequence of the args matters when using gcc?

gcc  -o fig fig.c -I./include ./lib/libmylib.a -g

gcc -g  fig.c  -o fig -I./include ./lib/libmylib.a

gcc -g -o fig fig.c -I./include ./lib/libmylib.a

It seems that t开发者_StackOverflowhe gcc accept different kinds of sequence. However, what is a not acceptable sequence? Does the sequence of arguments matters?


One sequence that does matter is where you put libraries if you specify -static linkage.

Basically, if you choose to statically link libraries in, the libraries should be specified after your code, as GCC will scan the code first for external library dependencies and then check the libraries to bring in. If you specified the libraries before the code that needs them, GCC would scan and determine no libraries were needed, and you'd end up with linker errors.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜