sqrt() in math.h - Programmers Heaven

Howdy, Stranger!

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


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

sqrt() in math.h

Gregry2Gregry2 Posts: 607Member
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...



  • AsmGuru62AsmGuru62 Posts: 6,519Member
    [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]
  • Gregry2Gregry2 Posts: 607Member
    I just forgot to link the math library...sorry.
Sign In or Register to comment.