This is the mail archive of the cygwin@sources.redhat.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: 'undefined reference' encountered building compface


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 <khan at NanoTech dot Wisc dot EDU>:

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 <errno.h>
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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]