[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: why is the symbol __errno not resolving from libm.a ?

> Date: Fri, 08 Jun 2001 18:22:07 +0900
> From: Henry Minsky <hqm@xxxxxxx.edu>

> I am getting this linker error when i try to link the code. The makefile 
> first builds a library called "libgspd.a",
> and then when it comes time to link to the main program, gpsd, something
> in the math library gives this weird error about not finding "__errno".
> Can anyone tell me what might be causing this? Is something wrong with ar 
> in the cris tools?
> Is there some other library I should be putting in the path for statically 
> linking?
> I fixed this temporarily by defining a variable "__errno" in one of the files
> i.e.,  "int __errno;"
> in one of my files, but that is obviously a hack ...

First of all, I believe you're fine with that hack as long as
your program does not depend on errno being set in the math
functions you use from libm; they set errno for out of range
parameters like log (0) and log (-1).  If your program *does*
depend on that, it looks like it could just check __errno

While I haven't seen your code or tried to replicate the
situation, I believe this problem is due to uclibc not being
compatible with the installed libm, which is compiled for use
with glibc.  They use different means to set errno.
Unfortunately the glibc in cris-dist-1.11 wasn't usable in
general.  Yes, it's messy and will be solved in the next
cris-dist release, usable with the next devboard_lx release.

Here's a *temporary* measure, if you really need errno set from
libm: Link your code without -lm and check what "undefined
reference" errors you get; perhaps it's only "fmod", but likely
others too.  Then find the source code for those functions (and
the functions they depend on) in the cris-dist-glibc-1.11.tar.gz
tarball and compile them with your program.  This process might
take some time.  IMPORTANT: This would mean you don't use glibc
simply as a library and those library function can now be
considered part of your program.  Hence according to the LGPL
you'd then have to give the user of the program access to the
source code for your program.  If you're making a product for
sale, know that most vendors don't want that situation.  From
looking at your mail address I believe you've heard all about
that before. :-)

brgds, H-P