Advertisement

GCC and math.h problem

Started by January 03, 2002 04:24 PM
1 comment, last by PIPE_BOMB 22 years, 9 months ago
I have just started programming in linux and I am porting some of my software. I need to use the math functions. I was getting errors about "undefined reference sqrt" when compiling with gcc. I thought it was something wrong with my code, so I checked the man pages for ''sqrt'' and made a small test program which has the same error. #include int main () { double test_var; test_var = sqrt(3.00f); return 0; } I used this line to compile the file: gcc -o test test.c I am using Mandrake 8.1, gcc 2.9.6 and glibc 2.2.4 I am I missing something? thanks in advance for any help!
make sure the function is declared in "math.h" and that you are binding "glibc" correctly and it contains the "sqrt" function definition.

To the vast majority of mankind, nothing is more agreeable than to escape the need for mental exertion... To most people, nothing is more troublesome than the effort of thinking.
To the vast majority of mankind, nothing is more agreeable than to escape the need for mental exertion... To most people, nothing is more troublesome than the effort of thinking.
Advertisement
thanks for the help, it pointed me to the problem. Other people have been having the the problem. You need to add -lm to link the maths library.

This topic is closed to new replies.

Advertisement