Jump to content
  • Advertisement

Archived

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

likeafox

math.h does nothing

This topic is 5303 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'm compiling my C program using gcc296 on RedHat9 line 12 of my program does not generate any errors: #include <math.h> line 624 does generate an error: user.tX += tan(user.direction) * vc; it gives me this error: In function `frame': : undefined reference to `tan' My question is: "Why?" Why does tan() not seem to be defined in math.h, and what can I do to aid this? And what could be a possible alternative to tan() if I can't find a solution? [edited by - likeafox on April 9, 2004 7:18:54 PM]

Share this post


Link to post
Share on other sites
Advertisement
I think user.direction(whatever it is) should be a double.

You should include instead of anyways.

Jehovah is viewed by Gnostics as fundamentally evil, jealous, rigid, lacking in compassion and prone to genocide.

Share this post


Link to post
Share on other sites
is this a COMPILE error or a LINK error? I think it might be a link error, and you need to LINK TO the math library (sometimes something like math.o or math.lib, other times a compiler switch like /m /lm or someting, look at the docs for linking to the math lib if it IS a linker error).

Share this post


Link to post
Share on other sites
user.direction is a float. I've tried type casting it as a double, but that doesn't do the trick either.

edit: it says /tmp/ccUKGKJQ.o(.text+0x1d6f): before the error. I can't clearly tell if it's a compiler error or a link error, but I assumed it was a compiler error.

[edited by - likeafox on April 9, 2004 7:26:03 PM]

Share this post


Link to post
Share on other sites
Try adding -lm to your command line. It seems like a linker error, and -lm should link with the math library for gcc.

Share this post


Link to post
Share on other sites
quote:
Original post by Demiurge666
You should include <cmath> instead of <math.h> anyways.


1) Learn to use HTML in your posts.
2) Learn to read. The original poster specified C, not C++.

Share this post


Link to post
Share on other sites
I seem to recall having this problem before--you should definitely make sure you are linking to the math library. The gcc switch you want to add is -lm.

Also, yeah, if you're using floats you should use tanf().

[Edit: Whoops, got beaten to it. =)]

[edited by - lancekt on April 9, 2004 7:32:49 PM]

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!