1.5.7 undefined reference to getreent when using mno-cygwin

list@list.dk list@list.dk
Fri Mar 5 13:33:00 GMT 2004


I have a pure Win32 console program which I am trying to compile under Cygwin. I am
including the following libraries

	-lws2_32 -lrpcrt4 -luuid -lrpcns4 -lpsapi -liphlpapi

and am using a host of Win32 calls for threading, sockets, semaphores, etc.

I know that I need to compile with the option -mno-cygwin to be able to run the program on
a computer without the cygwin.dll, which is what I want, however, when I add this option I
get the following linker error:

	undefined reference to `___getreent'

This is my linker statement:

CoreMain.o CoreLibrary.a -Wl,--rpath -Wl,/usr/local/lib  -o CoreTest -mno-cygwin -lws2_32
-lrpcrt4 -luuid -lrpcns4 -lpsapi -liphlpapi

I have found that I get this for every line in the code where I use either

	printf("...\b..."); fflush(stdout);

and when I comment out these the error goes away, but jumps to the next line or file where
I use this or something like it. I must admit that I have not tried removing all hundreds
of them, just the first 15 or so...

I have tried to include all sorts of libraries instead of the cygwin.dll and actually,
when I include the -lpthread it compiles, but then the program crashes when I start using
threads and semaphores...

As I mentioned above, when I do not state -mno-cygwin, everything works fine and the
program runs perfectly! But then it needs the cygwin.dll, of course...

I found a few references to this on the web, mostly promoting the compiler directive

	-D __CYGWIN__

which I have tried, but to no avail...

Below is a snippet of output from the linker. I hope this will make sense to somebody out
there, who can tell me what to include in my linker statement...

Thank you very much in advance!

Best regards,

Thor List

Linker output (with a few comments):

CoreMain.o CoreLibrary.a -Wl,--rpath -Wl,/usr/local/lib  -o CoreTest -mno-cygwin -lws2_32
-lrpcrt4 -luuid -lrpcns4 -lpsapi -liphlpapi

CoreMain.o(.text+0x1d4): In function `main':
/cygdrive/d/cm/psyclone/CoreLibrary/CoreMain.cpp:259: undefined reference to `___getreent'

	// line 259: 	getchar();

CoreLibrary.a(Network.o)(.text+0x5c97): In function `_ZN7Network8unitTestEv':
/cygdrive/d/cm/psyclone/CoreLibrary/Network.cpp:653: undefined reference to `___getreent'
: undefined reference to `___getreent'

	// line 680:	printf(".\b"); fflush(stdout);

: undefined reference to `___getreent'

	// line 682:	printf("o\b"); fflush(stdout);

: undefined reference to `___getreent'

	// line 684:	printf("O\b"); fflush(stdout);

: more undefined references to `___getreent' follow

	// line 703:	printf(" \b"); fflush(stdout);

collect2: ld returned 1 exit status
make.exe: *** [CoreTest] Error 1

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