Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

PIPE_BOMB

GCC and math.h problem

This topic is 6039 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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!

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!