Problem with gcc compiler 
Author Message
 Problem with gcc compiler

Please help!

I have a question for anybody who would take his time and answer.

I am trying to compile a program with some math. functions as follows:

gcc -lm -o program progra.c

and I receive an error message of this type:

ld: undefined symbol
   _sqrt
   _floor
   _tan  etc.

Unfortunately, nobody I asked in my school knew how to solve it.
Any help would be greatly appreciated.

Regards, Igor

P.S. I use SunOS v4.1.2



Mon, 26 May 1997 06:38:42 GMT  
 Problem with gcc compiler

Quote:
>I am trying to compile a program with some math. functions as follows:
>gcc -lm -o program progra.c
>and I receive an error message of this type:
>ld: undefined symbol
>   _sqrt
>   _floor
>   _tan  etc.

15.2:   I'm trying to do some simple trig, and I am #including <math.h>,
        but I keep getting "undefined: _sin" compilation errors.

A:      Make sure you're linking with the correct math library.  For
        instance, under Unix, you usually need to use the -lm option,
        and at the _end_ of the command line, when compiling/linking.
        See also question 12.14.

However I wonder some (e.g. DECs) linker can handle -lm as a first
argument.

Hans Friedrich
--
Hans Friedrich Steffani
Institut fuer Elektrische Maschinen und Antriebe
TU Chemnitz-Zwickau



Mon, 26 May 1997 16:37:39 GMT  
 Problem with gcc compiler


Quote:
>Please help!
>I am trying to compile a program with some math. functions as follows:
>gcc -lm -o program progra.c
>and I receive an error message of this type:

>ld: undefined symbol
>   _sqrt
>   _floor
>   _tan  etc.

try         gcc -o program progra.c -lm

--

=========================================================================
Tasos Drosopoulos



Mon, 26 May 1997 21:45:05 GMT  
 Problem with gcc compiler

Quote:
>I have a question for anybody who would take his time and answer.
>I am trying to compile a program with some math. functions as follows:

>gcc -lm -o program progra.c
>[...]

I tried to respond by email.  However, mail bounced due to the invalid
address in your article's header.

This is actually a unix programming question, not a C language question.
It belongs in comp.unix.programmer, not in comp.lang.c.
However, it's misposted to comp.lang.c often enough (I think this is the
third time I've seen it this week) that it's answered in the comp.lang.c FAQ

15.2:   I'm trying to do some simple trig, and I am #including <math.h>,
        but I keep getting "undefined: _sin" compilation errors.

A:      Make sure you're linking with the correct math library.  For
        instance, under Unix, you usually need to use the -lm option,
        and at the _end_ of the command line, when compiling/linking.
        See also question 12.14.

Try saying "gcc -o program progra.c -lm"

You might also try "man cc" and "man ld".  The answer should be there too.

The comp.lang.c FAQ, along with all the other FAQs, can be found on
rtfm.mit.edu.  While you're at it, you might want to look at the FAQ
for comp.unix.questions.

--

--



Tue, 27 May 1997 05:00:39 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Problem with gcc compiler for ARM processor

2. Problems porting GCC compiler to Gould

3. gcc compiler problem with file inode

4. problems withs using gcc compiler on Linux and Win2000

5. MSDOS GCC COMPILER PROBLEMS

6. Libraries to link under Linux's gcc compiler

7. gcc compiler for win32??

8. gcc compiler options.

9. how to use gcc compiler in dos enviroment??

10. asm with GCC compiler in Linux

11. is there a gcc compiler available for NT?

12. GCC compiler warning

 

 
Powered by phpBB® Forum Software