GCC: problem with library search path when targeting mingw

Damien Fouilleul damien.fouilleul@laposte.net
Tue Aug 15 10:24:00 GMT 2006


I'm not sure that I agree with your assements, /usr/lib as always been 
available (at least displayed) as a default search path in 
'print-search-dirs' even when using the -mno-cygwin switch, but for some 
reason, has always been ignored when  linking for MinGW.

I think the problem has to do with 
'/usr/lib/gcc/i686-pc-mingw/3.4.4/../../..' in the search paths, I'm not 
sure if this path was available in the previous packages of 
gcc/mingw-runtime/binutils  (I don't feel like downgrading to check it 
out :) ), but this is the one that's giving me trouble rather than 
/usr/lib, so I don't think -Wl,-nostdlib will be of any help.

I agree with you that -mno-cygwin has been a bad choice, as it requires 
a lot of hacking around to get some configure scripts to recognize/use 
this option when cross-compiling autotools based packages for MinGW, but 
until this recent problem, I've always managed to get by without 
tweaking configure scripts, typically overriding CC, CXX, CPPFLAGS, 
etc... on the command line was enough.

Damien

Christopher Faylor wrote:

>>  Thanks for the report.  This has been mentioned before, it's a problem in
>>gcc's 'specs', which are command-line pattern matching strings (more-or-less)
>>used by the gcc compiler driver to select the right options for the
>>sub-programs that it invokes.  It's basically a consequence of the fact that
>>we're using the same driver to drive a native compiler /and/ a cross-compiler;
>>normally, a cross-compiler wouldn't include any of the system paths such as
>>/usr/lib at all, but for a native compiler that's exactly what you want it to
>>do.
>
>The /usr/lib inclusion is actually likely to be a binutils "problem"
>since ld includes /usr/lib by default.  Possibly adding -Wl,-nostdlib to
>the command line would help.
>
>In any event, I really think that -mno-cygwin is 1) a bad choice for an
>option name and 2) a bad way to accomplish what is essentially
>cross-compilation.  I regret that I stood by idly and watched that
>option go into gcc.
>
>cgf



Damien Fouilleul wrote:
> hello,
>
> I'm a big fan of cygwin and I use it a lot to compile mingw apps,
> however with the latest mingw-runtime, I'm having trouble running
> configure scripts successfully as test such 'dlopen() in -ldl', which
> used to fail for mingw target (as expected) now succeeds. This causes
> havoc in compilation as the resulting config.h file contains reference
> to APIs not supported by mingw.
>
> after having a look at gcc -mno-cygwin -print-search-dirs, I think I may
> have found the culprit in the following element of the library search 
> path:
> '/usr/lib/gcc/i686-pc-mingw/3.4.4/../../..', as this points back
> straight at /usr/lib, the cygin main library path. This means now that
> the following command
>
> $ gcc -mno-cygwin dlopen-test.c -dl
>
> Now passes with flying colors. I have to edit all my config.h as I do
> not know of any way to remove this path from the search paths
>
> Similarily, I have a similar but less serious problems with headers
> paths for files such as math.h, float.h, these are available for both
> cygwin and mingw, but they are different files.Unfortunately,
> "/usr/lib/gcc/i686-pc-cygwin/3.4.4/include" has precedence over
> '/usr/lib/gcc/i686-pc-mingw32/3.4.4/../../../../i686-pc-mingw32/include'
> when targetting mingw by default, therefore the cygwin version is chosen
> over the mingw one.
> In 99% of cases, this is usually not a problem, as the files are nearly
> identical, but they are some Microsoft specific code in the mingw, which
> is required to compile Trolltech QT, for example.
> If i use the following compiler option '-isystem /usr/include/mingw',
> then everything works fine.
>
> I hope this help
>   Damien
>
> --------
>
> For reference:
>
> binutils-20060709-1
> gcc-3.4.4-1
> mingw-runtime-3.10.1
>
> $ gcc -mno-cygwin -print-search-dirs
> install: /usr/lib/gcc/i686-pc-mingw32/3.4.4/
> programs:
> =/usr/lib/gcc/i686-pc-mingw32/3.4.4/:/usr/lib/gcc/i686-pc-mingw32/3.4.4/:/usr/lib/gcc/i686-pc-mingw32/:/usr/lib/gcc/i686-pc-mingw32/3.4.4/:/usr/lib/gcc/i686-pc-mingw32/:/usr/libexec/gcc/i686-pc-mingw32/3.4.4/:/usr/libexec/gcc/i686-pc-mingw32/:/usr/lib/gcc/i686-pc-mingw32/3.4.4/:/usr/lib/gcc/i686-pc-mingw32/:/usr/lib/gcc/i686-pc-mingw32/3.4.4/../../../../i686-pc-mingw32/bin/i686-pc-mingw32/3.4.4/:/usr/lib/gcc/i686-pc-mingw32/3.4.4/../../../../i686-pc-mingw32/bin/ 
>
> libraries:
> =/usr/lib/gcc/i686-pc-mingw32/3.4.4/:/usr/lib/gcc/i686-pc-mingw32/3.4.4/:/usr/lib/gcc/i686-pc-mingw32/3.4.4/../../../../i686-pc-mingw32/lib/i686-pc-mingw32/3.4.4/:/usr/lib/gcc/i686-pc-mingw32/3.4.4/../../../../i686-pc-mingw32/lib/:/usr/lib/gcc/i686-pc-mingw32/3.4.4/../../../i686-pc-mingw32/3.4.4/:/usr/lib/gcc/i686-pc-mingw32/3.4.4/../../../:/lib/i686-pc-mingw32/3.4.4/:/lib/:/usr/lib/i686-pc-mingw32/3.4.4/:/usr/lib/ 
>
>
> $ gcc -print-search-dirs
> install: /usr/lib/gcc/i686-pc-cygwin/3.4.4/
> programs:
> =/usr/lib/gcc/i686-pc-cygwin/3.4.4/:/usr/lib/gcc/i686-pc-cygwin/3.4.4/:/usr/lib/gcc/i686-pc-cygwin/:/usr/lib/gcc/i686-pc-cygwin/3.4.4/:/usr/lib/gcc/i686-pc-cygwin/:/usr/libexec/gcc/i686-pc-cygwin/3.4.4/:/usr/libexec/gcc/i686-pc-cygwin/:/usr/lib/gcc/i686-pc-cygwin/3.4.4/:/usr/lib/gcc/i686-pc-cygwin/:/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/bin/i686-pc-cygwin/3.4.4/:/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/bin/ 
>
> libraries:
> =/usr/lib/gcc/i686-pc-cygwin/3.4.4/:/usr/lib/gcc/i686-pc-cygwin/3.4.4/:/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/lib/i686-pc-cygwin/3.4.4/:/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/lib/:/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../i686-pc-cygwin/3.4.4/:/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../:/lib/i686-pc-cygwin/3.4.4/:/lib/:/usr/lib/i686-pc-cygwin/3.4.4/:/usr/lib/ 
>
>
> $ cpp -mno-cygwin --verbose test.c
> Reading specs from /usr/lib/gcc/i686-pc-mingw32/3.4.4/specs
> Configured with: /gcc/gcc-3.4.4/gcc-3.4.4-1/configure --verbose
> --prefix=/usr --exec-prefix=/usr --sysconfdir=/etc --libdir=/usr/lib
> --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info
> --enable-languages=c,ada,c++,d,f77,java,objc --enable-nls
> --without-included-gettext --enable-version-specific-runtime-libs
> --without-x --enable-libgcj --disable-java-awt --with-system-zlib
> --enable-interpreter --disable-libgcj-debug --enable-threads=posix
> --enable-java-gc=boehm --disable-win32-registry --enable-sjlj-exceptions
> --enable-hash-synchronization --enable-libstdcxx-debug : (reconfigured)
> Thread model: posix
> gcc version 3.4.4 (cygming special) (gdc 0.12, using dmd 0.125)
> /usr/lib/gcc/i686-pc-mingw32/3.4.4/cc1.exe -E -quiet -v -D__MSVCRT__
> -D__MINGW32__ -DWIN32 -D_WIN32 -D__WIN32 -D__WIN32__ -DWINNT -idirafter
> /usr/lib/gcc/i686-pc-mingw32/3.4.4/../../../../include/w32api -idirafter
> /usr/lib/gcc/i686-pc-mingw32/3.4.4/../../../../i686-pc-mingw32/lib/../../include/w32api 
>
> test.c -mno-cygwin -mtune=pentiumpro
> ignoring nonexistent directory "/usr/local/include/mingw"
> ignoring duplicate directory "/usr/include/mingw"
> ignoring duplicate directory
> "/usr/lib/gcc/i686-pc-mingw32/3.4.4/../../../../i686-pc-mingw32/lib/../../include/w32api" 
>
> #include "..." search starts here:
> #include <...> search starts here:
> /usr/lib/gcc/i686-pc-cygwin/3.4.4/include
> /usr/lib/gcc/i686-pc-mingw32/3.4.4/../../../../i686-pc-mingw32/include
> /usr/lib/gcc/i686-pc-mingw32/3.4.4/../../../../include/w32api
> End of search list.
> # 1 "test.c"
> # 1 "<built-in>"
> # 1 "<command line>"
> # 1 "test.c"
> # 1 "/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/float.h" 1 3 4
> # 2 "test.c" 2
>
> int main(int argc, char **argv) {
>    return 0;
> }
>
>
>



--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/



More information about the Cygwin mailing list