Help: compiler doesn't recognize math functions

Help: compiler doesn't recognize math functions

Post by Francois Forste » Wed, 19 Jul 1995 04:00:00



Hi,

I am running gcc on a program that uses exp, log and pow.
I use -lm as an option for the math library but it tells me
undefined reference to 'exp', 'log' and 'pow'.

Suggestion will be greatly appriciated.

Francois Forster.

 
 
 

Help: compiler doesn't recognize math functions

Post by leung leu » Thu, 20 Jul 1995 04:00:00


: Hi,
:
: I am running gcc on a program that uses exp, log and pow.
: I use -lm as an option for the math library but it tells me
: undefined reference to 'exp', 'log' and 'pow'.
:
: Suggestion will be greatly appriciated.
:
        I have no such a problem ... I give you some suggestion ...
I found that the command line

        gcc -lm -o xxx xxx.c  

does not work ... You have to move the -lm option to the end of the line

        gcc -o xxx xxx.c -lm

(I am using slackware 2.3 , gcc 2.6.3 ...)

--
LL

 
 
 

Help: compiler doesn't recognize math functions

Post by avinge » Thu, 20 Jul 1995 04:00:00


You have to put the -lm at the very end of the command line.
ex:
gcc -Wall blah.c main.c -lm

>Hi,

>I am running gcc on a program that uses exp, log and pow.
>I use -lm as an option for the math library but it tells me
>undefined reference to 'exp', 'log' and 'pow'.

>Suggestion will be greatly appriciated.

>Francois Forster.


 
 
 

1. Linker doesn't find _sqrt and other math functions

With a new Slackware 1.2.0 distribution, gcc and ld both can not link the
following:

#include <math.h>
main()
{
float d=3.14;
sqrt(d);
return 0;

The error report is:
/tmp/cca003971.o: Undefined symbol _sqrt referenced from text segment

I tried gxx, -fno_builtin, -traditional, some other switches.

There must be a simple solution, right?

--
Zhenya Sorokin


Paper-mail : E. Sorokin, Gusshausstr. 27/359-9, 1040 Vienna, Austria
Voice-mail : +43(1)58801-3801, -3948
Flame-mail : /dev/null

2. Where can I ftp Ghostview?

3. functions: why doesn't this short function work?

4. URGENT: FTPD and NIS

5. Linux doesn't recognize NIC - Help Please

6. Anyone good with the GIMP?

7. Help - RH Linux doesn't recognize my CD-ROM

8. Apache LoadModule directive

9. Compiler Error -- doesn't find shred library 'libc.so.4'

10. Trouble finding C's math functions: log10(), sin, etc...

11. Liniux doesn't recognize my serial ports correctly-HELP!!!

12. Help - Adding RAM - Linux doesn't recognize

13. HELP: Red Hat install doesn't recognize my SCSI CD-ROM or Hard drives