How To Prevent Errors when Linking Programs with Math Functions
Older run-time libraries included the math library in the C run-time library. It was not necessary to specify the math library separately when compiling. If the compiler generates a message like this when linking a program that uses math functions: /tmp/ccDUQM4J.o: In function "main":
/tmp/ccDUQM4J.o(.text+0x19): undefined reference to "sqrt"
collect2: ld returned 1 exit status |
You need use the -lm option with GCC to link with the math libraries: # gcc -o program program.c -lm |
Make sure also to use the statement #include <math.h> in the source file. [Florian Schmidt] Why Doesn't the AHA1542C Card Work With Linux Why Don't lpr and/or lpd Work? See our index for more reviews Write a review and win an Apple Ipod
|