gcc -mno-cygwin creates cygwin executables!

Teun Burgers a.rburgers@freeler.nl
Wed Dec 12 12:15:00 GMT 2001

To sum up this thread:

consider the following program:

main () {

gcc -mno-cygwin -o zz.exe zz.c -lpthread will compile and build.
A cygcheck on zz.exe reveals that libcygwin.a is linked in. The
problem with this is that a configure script with CC='gcc -mno-cygwin'
will incorrectly find that libpthread.a is available with
AC_SEARCH_LIBS(pthread_create, -lpthread)

This comes about since gcc -mno-cygwin searches for libs in /usr/lib
and libpthread.a is a symlink to libcygwin.a

One way to fix this would be to break out the thread functions of
libcygwin.a into a separate libpthread.a. When you then link with
gcc -mno-cygwin, libcygwin.a is not linked in and the link will fail.
Apparantly for performance and technical reasons this is not
This has to do with libcygwin.a depending on the pthread functions.

Another would be to put the libpthread.a symlink in a directory that gcc
doesn't search, e.g. /usr/lib/cygwin, and add this library to the specs
for cygwin
What would be the problem with this approach?

There are 2 other alternatives that fix the configure problem:

1) How about making libpthread.a a dummy library with just one .o file
   with a dummy (empty) function? This does fix this particular
   configure problem, but might have side effects since the pthread
   are no longer in libpthread.a

2) include the pthread symbols in both libcygwin.a and libpthread.a?

Robert Collins wrote:

> Hmm. Why not put the win32 api checks in the configure script ahead of
> pthread?

What do you mean with that?


Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

More information about the Cygwin mailing list