sqrt() in math.h

Hey guys, It's been a million years since I touched here. I'm 20 now, and I kind of want to go back to what I used to do for fun when I was 15 or so.

Anyway, I have a very simple problem, even though I include math.h, I get an "undefined reference to "sqrt" error. I really am lost. Looking at math.h in /usr/include looks fine...of course. Any ideas? I'm not misspelling it or anything...



  • [color=Blue]Can you post the full error message? Try to create a simple project, like:

    int main ()
    double a = 5.9348873;
    double b = sqrt (a);
    return 0;
    That also does not work? If that works, then some additional code is affecting your project, like some obscure defines hidden in other .H files or something of that kind. MFC likes to do it a lot - with some defines from stdafx.h it excludes some functions included into WINDOWS.H file.

    Is the sqrt error the first one in a list of errors? If not - begin from the first one - in most cases a first error in C causes the rest of errors.[/color]
  • I just forgot to link the math library...sorry.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!