Does a sequence of arguments make sense 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

Gcc seems to accept different sequences. However, what is an unacceptable sequence? Does a sequence of arguments make sense?

+3
source share
1 answer

One sequence that matters is the placement of the libraries if you specify -staticlinkage.

Basically, if you decide to statically link libraries, the libraries should be listed after your code, since GCC first scans the code for the external library dependencies and then checks the libraries for input. If you specify libraries before the code they need, GCC will scan and determine which libraries are not needed, and you will get linker errors.

+4

All Articles