delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/03/05/10:15:19

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
X-Authentication-Warning: slinky.cs.nyu.edu: pechtcha owned process doing -bs
Date: Fri, 5 Mar 2004 10:14:48 -0500 (EST)
From: Igor Pechtchanski <pechtcha AT cs DOT nyu DOT edu>
Reply-To: cygwin AT cygwin DOT com
To: list AT list DOT dk
cc: cygwin AT cygwin DOT com
Subject: Re: 1.5.7 undefined reference to getreent when using mno-cygwin
In-Reply-To: <200403051028.i25ASVgr007553@grassmarket.ucs.ed.ac.uk>
Message-ID: <Pine.GSO.4.56.0403051013110.1570@slinky.cs.nyu.edu>
References: <200403051028 DOT i25ASVgr007553 AT grassmarket DOT ucs DOT ed DOT ac DOT uk>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 2.39

On Fri, 5 Mar 2004 list<at>list<dot>dk wrote:

> Hi,
>
> 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:
>
> g++ -g -O2 -D_GNU_SOURCE -D_REENTRANT -D_THREAD_SAFE -D WIN32 -D CYGWIN -D __CYGWIN__
> 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
>
>         getchar()
> or
>         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 snipped]

Thor,

You have to use -mno-cygwin for the whole compilation, not just for the
link line, otherwise the wrong headers get picked up.  IOW, don't add
"-mno-cygwin" to LDFLAGS -- instead, redefine CXX='g++ -mno-cygwin' (and
CC='gcc -mno-cygwin') and rebuild everything from scratch.
	Igor
-- 
				http://cs.nyu.edu/~pechtcha/
      |\      _,,,---,,_		pechtcha AT cs DOT nyu DOT edu
ZZZzz /,`.-'`'    -.  ;-;;,_		igor AT watson DOT ibm DOT com
     |,4-  ) )-,_. ,\ (  `'-'		Igor Pechtchanski, Ph.D.
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

"I have since come to realize that being between your mentor and his route
to the bathroom is a major career booster."  -- Patrick Naughton

--
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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019