order of -L options created by gcc for the linker
I'm having a problem with gcc placing the default gcc libraries (-L/usr/lib/gcc/x86_64-redhat-linux/3.4.5) ahead of the correct (newer) versions in the list of arguments being passed to ld.
In particular, if I specify -Wl,-L/usr/local/ext/lib in the line passed to gcc, the resultant ld command will have the default location of libraries for gcc prior to my -L/usr/local/ext/lib entry. As a result, the linker trys to link older libraries and fails.
In contrast, if I specify -L/usr/local/ext/lib in the line passed to gcc (no -Wl), the resultant ld command will have -L/usr/local/ext/lib prior to the gcc default library location and the link proceeds without error.
Why is this? I thought gcc would take any -Wl specified option and pass it straight on to ld, I wasn't expecting a different placement within the resultant command line.
This is causing a problem for me because our current build environment does not support a method for generating the -L without -Wl.
Are there other arguments that can be passed to gcc so that my -L path is before the compilers?
Any help in understanding this would be appriciated.