math.h lacks sqrt()

This is a discussion on math.h lacks sqrt() within the Tech Board forums, part of the Community Boards category; Having recently installed linux for the millionth time(trying out different distros) and deciding to use debian for my current work, ...

  1. #1
    'AlHamdulillah
    Join Date
    Feb 2003
    Posts
    790

    math.h lacks sqrt()

    Having recently installed linux for the millionth time(trying out different distros) and deciding to use debian for my current work, I upgrades GNU gcc up to version 3.2.3. I load up one of my old 3d mathematics projects, which includes math.h, and tried to compile it and I get compiling errors regarding sqrt(), specifically the "undefined reference to..." error.

    I was wondering if anyone else has had this problem and how I can fix it.

    thanks
    there used to be something here, but not anymore

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,548
    You need
    Code:
    gcc prog.c -lm
    That's LM in lowercase
    It tells the linker to link with the math library
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    'AlHamdulillah
    Join Date
    Feb 2003
    Posts
    790
    hmm... thanks man, wonder why I never had to do that before....
    there used to be something here, but not anymore

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. math.h
    By tsutharssan in forum C Programming
    Replies: 3
    Last Post: 07-03-2009, 02:24 PM
  2. undefined reference to sqrt
    By shamma in forum C Programming
    Replies: 1
    Last Post: 05-09-2009, 01:42 PM
  3. Replies: 5
    Last Post: 06-01-2006, 04:37 PM
  4. sqrt
    By modec in forum C Programming
    Replies: 3
    Last Post: 04-16-2003, 07:19 AM
  5. how sqrt ?
    By sambs1978 in forum C Programming
    Replies: 3
    Last Post: 09-20-2001, 08:14 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21