math.h not working? o.0

Tags
programming

 
Thread Tools Search this Thread
# 1  
Old 03-19-2002
Question math.h not working? o.0

Alright, umm i cant get this to work.
im looking at some example and a book i have.
when i try to compile my program i get an error message.
Code:
ld: 0711-317 ERROR: Undefined symbol: .sqrt
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.

I did #include<math.h> after my stdio.h at the top of the program. I even tried replacing sqrt with the power function; same error. (except it was .pow instead of .sqrt)

this is my function
Code:
float squareRootValue(int i){
      return (float) sqrt(i);
     }

I'm passing a number to the function that will be rooted. does anyone know whats wrong? if you need more code, please let me know. im on an AIX 4 system.
thanks!
primal
# 2  
Old 03-20-2002
You need to search the math library. On my system, I would do something like:
cc prog.c -lm -o prog
to compile that program.
# 3  
Old 03-24-2002
Yes you need to add "-lm"

That is to link the math library when linking your program

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
Math lawsongeek UNIX for Dummies Questions & Answers 11 05-07-2015 12:03 AM
Linux Math Help minkyboodle UNIX for Dummies Questions & Answers 3 11-11-2013 08:36 PM
Math function with C Fingerz Programming 7 11-23-2012 05:14 PM
Math Tool PranavEcstasy Shell Programming and Scripting 2 08-23-2012 08:40 AM
Need help with AWK math brianjb Shell Programming and Scripting 3 04-26-2012 03:21 PM
Math action in ksh LiorAmitai Shell Programming and Scripting 4 07-19-2011 10:53 AM
math help rockbike Shell Programming and Scripting 2 04-15-2009 12:20 AM
math in unix khestoi UNIX for Dummies Questions & Answers 13 03-04-2009 06:18 AM
math.h in makefile kermit Programming 2 09-15-2008 05:30 AM
some math problems in C cdfd123 Programming 4 08-19-2007 08:39 PM
something about <math.h> blf0 Programming 4 03-10-2006 12:44 AM
Math Square Root davex4285 Shell Programming and Scripting 3 01-29-2006 10:03 PM
Math calculation help sickboy Shell Programming and Scripting 4 06-11-2005 02:22 PM