Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sources DOT redhat DOT com Delivered-To: mailing list cygwin AT sources DOT redhat DOT com X-Authentication-Warning: hp2.xraylith.wisc.edu: khan owned process doing -bs Date: Wed, 7 Feb 2001 22:38:38 -0600 (CST) From: Mumit Khan To: Mithras cc: cygwin AT cygwin DOT com Subject: Re: 'undefined reference' encountered building compface In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Wed, 7 Feb 2001, Mithras wrote: > Hi, I'm running cygwin on Win2k, I'd like to build Xemacs myself to > tweak the memory management. > > My problem is that compface, which the Xemacs install HOWTO says > hasn't been changed in generations, fails to build on some very > standard symbols: > > $ make > gcc -g -o compface cmain.o compface.o libcompface.a > cmain.o(.text+0x25a): undefined reference to `errno' > cmain.o(.text+0x260): undefined reference to `sys_nerr' > cmain.o(.text+0x267): undefined reference to `errno' > cmain.o(.text+0x275): undefined reference to `sys_errlist' > > I've searched for previous discussion, and the closest I've found so > far is from 'Using h_errno, errno etc Cygwin DLL globals [Re: Making > wget]' by Mumit Khan : I was hoping that post would give folks enough of a clue to do the right thing. Here it is again: Cygwin, unlike some of the other existing Unix systems, does not define an external variable named errno, sys_nerr and sys_errlist. ``errno'' is actually a macro, and with more and more multithreaded systems, that is become more common. The names of sys_nerr and sys_errlist were at some point changed to _sys_nerr and _sys_errlist and imported from the DLL (the fact that these are also not exported without the leading underscores is a mistake IMO). So, how do you handle this? 1. Anywhere there is errno used, make sure that you include and wherever you see code like the following: extern int errno; change that to: #ifndef errno extern int errno; #endif 2. Anywhere you see sys_nerr and sys_errlist, make sure your code does not declare them as: extern int sys_nerr; /* ... */ and instead, use the declarations provided by the runtime headers. Then build it as following: gcc -Dsys_nerr=_sys_nerr -Dsys_errlist=_sys_errlist ... (or change the code appropriately, or better yet, have the configuration tools do this for you if the package is autoconfigured). Portable code should be using the standard strerror(), not these magic variables anyway. 90+% of the time strerror() is you need. Regards, Mumit -- Want to unsubscribe from this list? Check out: http://cygwin.com/ml/#unsubscribe-simple