Undefined Reference to std functions when compiling

Undefined Reference to std functions when compiling

Post by Safa Sadeghpou » Mon, 20 Nov 1995 04:00:00



Hi,

When trying to compile a C program gcc goes through the sources
and makes the .o files and everything seems fine. In the last
step when it finally is linking the object files it gives me
this error:

Make_weights.o(.text+0x45): undefined reference to `exp'
Make_weights.o(.text+0x91): undefined reference to `exp'
veclength.o(.text+0x45): undefined reference to `sqrt'
make: *** [lim] Error 1                                  

The include statement is there in the source, and all the trivial
causes for this type of error seem to have been checked.

All help is very appreciated.

Thanks and take care.

Safa

 
 
 

Undefined Reference to std functions when compiling

Post by Rene Pijlma » Mon, 20 Nov 1995 04:00:00



>this error:

>Make_weights.o(.text+0x45): undefined reference to `exp'
>Make_weights.o(.text+0x91): undefined reference to `exp'
>veclength.o(.text+0x45): undefined reference to `sqrt'
>make: *** [lim] Error 1                                  

Safa,

Add '-lm' to your link command line. This tells the linker to use
the math library.

HTH,
--
Rene Pijlman

Anyone can hold the helm when the sea is calm.
                -- Publilius Syrus

 
 
 

Undefined Reference to std functions when compiling

Post by Charles To » Mon, 27 Nov 1995 04:00:00




> >this error:

> >Make_weights.o(.text+0x45): undefined reference to `exp'
> >Make_weights.o(.text+0x91): undefined reference to `exp'
> >veclength.o(.text+0x45): undefined reference to `sqrt'
> >make: *** [lim] Error 1                                  
> Add '-lm' to your link command line. This tells the linker to use
> the math library.

go to /lib and do a strings on libm.a and see if exp and sqrt are coming
through.  If so, try putting -lm the last thing on your command line
to gcc.  Don't know why, but it does that to mee sometimes.

charles todd

--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
JFK's Last Words:        I have half a mind to quit this job.
--------
Q: What's the difference between a rooster and a lawyer?
A: A rooster clucks defiance.
--------
The very powerful and the very stupid have one thing in common.
Instead of altering their views to fit the facts, they alter the facts
to fit their views ... which can be very uncomfortable if you happen to
be one of the facts that needs altering.
                -- Doctor Who, "Face of Evil"