'undefined reference to exp' erron when compiling

'undefined reference to exp' erron when compiling

Post by Anomal » Sun, 23 Aug 1998 04:00:00



Sigh - OK - I figured out the problem I was having with explicitly
compiling with libraries (the -l option automatiucally prefixes 'lib'
and appends '.a' to the end of what follows the -l option). So I used
c++ -lm prog.c (instead of -llibm) and low and behold the linker did not
complain about non-existant files this time - However I am still getting
the 'undefined reference to exp' error from the linker - I always
thought that exp was part of the standard math lib (its prototype is in
math.h after all). Is this not the case? Any additional suggestions
would be very much appreciated.

Sincerely,
Getting reall pissed : )

 
 
 

'undefined reference to exp' erron when compiling

Post by Anomal » Mon, 24 Aug 1998 04:00:00


Grrrr .... Heh - It would seem that the -l option must follow the source
files being compiled instead of preceeding them - Oh well - Problem
solved - Many thanks to those that took time to offer suggestions.

Anomaly


> Sigh - OK - I figured out the problem I was having with explicitly
> compiling with libraries (the -l option automatiucally prefixes 'lib'
> and appends '.a' to the end of what follows the -l option). So I used
> c++ -lm prog.c (instead of -llibm) and low and behold the linker did
> not
> complain about non-existant files this time - However I am still
> getting
> the 'undefined reference to exp' error from the linker - I always
> thought that exp was part of the standard math lib (its prototype is
> in
> math.h after all). Is this not the case? Any additional suggestions
> would be very much appreciated.

> Sincerely,
> Getting reall pissed : )


 
 
 

'undefined reference to exp' erron when compiling

Post by Rob Kom » Mon, 24 Aug 1998 04:00:00


: Sigh - OK - I figured out the problem I was having with explicitly
: compiling with libraries (the -l option automatiucally prefixes 'lib'
: and appends '.a' to the end of what follows the -l option). So I used
: c++ -lm prog.c (instead of -llibm) and low and behold the linker did not
: complain about non-existant files this time - However I am still getting
: the 'undefined reference to exp' error from the linker - I always
: thought that exp was part of the standard math lib (its prototype is in
: math.h after all). Is this not the case? Any additional suggestions
: would be very much appreciated.
:

Are you linking in any other libraries after libm?  If so, a routine in
one of them may include `exp', but if that object wasn't linked in when
libm was processed, then you'll get the undefined reference message.
In general, you should put `-lm' at the end of the list of libraries
to link in.

Cheers,
Robert Komar            Physics Dept., Univ. of British Columbia, Canada
                        (stationed at the Sudbury Neutrino Observatory)
My mail address can be got from the following Unix command: