Link to home
Start Free TrialLog in
Avatar of rhigg
rhigg

asked on

Problem with #include<math.h>

In two instances, i have compiled programs using the
math.h and string.h files, only to get the following error:

(for math.h)

ld: 0711-317 ERROR: undefined symbol: .sqrt
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more info.

I am compiling on AIX.

The header files are where they ought to be.  I can include
stdio.h, from the same directory, without any problems.

a: what might be the cause?
b: can i link these header files in through a different method?

even this simple test will generate the above error

#include <stdio.h>
#include <math.h>

main()
{
    printf("%f", sqrt(10.0));
}


Using string.h in a similar simple test generates the same
errors.
Avatar of jji
jji

If you use math.h you must use '-lm' switch with c89 (or whatever is your compiler).
  'c89 foo.c -o test -lm'
ASKER CERTIFIED SOLUTION
Avatar of mliberi
mliberi

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rhigg

ASKER

Both responses work for me.  What is the difference in this forum between a comment (jji) and an answer?(mliberi).

In other words, whats the criteria for assigning the points to the response?


Avatar of ozo
You can only assign points to the "answer", but you can post another question to assign additional points to another person.
If you prefer to assign the points to jji, you can reject the proposed answer, and ask jji to resubmit an answer.
Or, you can post a question in Customer Support to ask linda to help you split the points.