order of switches

Joe Buck jbuck@synopsys.COM
Thu Aug 12 13:11:00 GMT 1999


>   It appears that the order of switches that I give to g++
>   is critical to how it works. It may silently ignore -I or -l
>   if they aren't in the correct place. That seems weird and
>   causes problems, e.g.,

This is a beginner question.

gcc's behavior is the same as that of all Unix C compilers: the
order of the switches most definitely matters for include file
directories and libraries.  You are specifying the order in which
include directory paths and libraries are searched.  Libraries
are only searched for symbols that are undefined at a particular
point.  Similarly, for headers, the order of -I switches affects
handling of recursive includes.

>   I just grep'ed man g++ for "order" and it there were no matches.

The man pages are very minimal guides to the option flags.  The real
documentation of GCC is in the texinfo files.



More information about the Gcc mailing list