My original question:
> I have a problem when using gcc with programs that require the maths
> library (-lm).
>
> I have installed gcc (version 2.6.0), and I'm using the Sun libraries
> under SunOS 4.1.3_U1 (I've tried using the gnu libraries, but I
> had so much grief trying to set them up that I gave up).
>
> When I compile (some) things using the -lm option, I get the
> following message:
>
> ld: Undefined symbol
> __lib_version
> collect2: ld returned 2 exit status
>
> If, rather than using -lm, I explicitly name the library on the command
> line, (e.g. gcc testmath.c /usr/lib/libm.a), the problem goes away and
> it compiles ok.
> Now this is a pain when compiling gnu stuff as I have to edit Makefiles
> to change any -lm's to /usr/lib/libm.a.
>
> Has anyone else seen this, and have you a solution for it?
>
> An example bit of code which shows the problem:
>
> /* testmath.c */
> /* compile with "gcc testmath.c -lm" */
> #include <math.h>
> #define PI 3.1415926
>
> main()
> {
> double a,b;
>
> b=pow(a,2.0);
> }
> /* end of testmath.c */
>
First of all, I was using gcc because some things require it (particularly
if they are partly c++ based).
The problem turned out to be the fact that my LD_LIBRARY_PATH was set
to something else, to point to /usr/lang/SC2.0.1; we have the SPARCworks
compiler as well. If I do:
gcc testmath.c /usr/lang/SC2.0.1/libm.a
I get the lib_version message.
If I do
gcc testmath.c -L/usr/lib -lm
Then it's fine. Obviously the SPARCworks math lib is incompatible with
gcc. So the solution is to unsetenv LD_LIBRARY_PATH before
doing make.
Thanks to:
Anthony.Worrall@reading.ac.uk (Anthony Worrall)
B.Bretthauer@dlr.de (Bernward Bretthauer)
Casper Dik <casper@fwi.uva.nl>
Kevin.Sheehan@uniq.com.au (Kevin Sheehan {Consulting Poster Child})
mcain@mcs.drexel.edu (Mark Cain)
ptribble@hgmp.mrc.ac.uk (Peter C. Tribble)
raoul@MIT.EDU
This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:10:13 CDT