473,320 Members | 1,879 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

math.h problem -> sqrt undefined

Hi

I'm having a bit of problem trying to compile
a program..... which uses math.h

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

double sxy, sxx, syyy;
..
..
..
..
r = sxy / sqrt( sxx * syyy );
When I compile I get undefined reference to 'sqrt'
now the funny thing is that I use the function abs
which is the math.h function. I'm sort of at a lose end
does anybody have any ideas ?

Thanks
David

Nov 14 '05 #1
3 2395
LeTubs <dl*****@yahoonospam.co.uk> wrote:
I'm having a bit of problem trying to compile
a program..... which uses math.h #include <stdio.h>
#include <stdlib.h>
#include <math.h> double sxy, sxx, syyy;
.
r = sxy / sqrt( sxx * syyy ); When I compile I get undefined reference to 'sqrt'
now the funny thing is that I use the function abs
which is the math.h function. I'm sort of at a lose end
does anybody have any ideas ?


Have you read the FAQ? "Undefined reference" is always a linker,
not a compiler problem. You're not linking against the math
library. You probably need to add "-lm" to the command you use
for linking the program.
Regards, Jens
--
\ Jens Thoms Toerring ___ Je***********@physik.fu-berlin.de
\__________________________ http://www.toerring.de
Nov 14 '05 #2
On Fri, 25 Jun 2004 01:41:46 +0100, "LeTubs" <dl*****@yahoonospam.co.uk>
wrote:
When I compile I get undefined reference to 'sqrt'
now the funny thing is that I use the function abs
which is the math.h function. I'm sort of at a lose end
does anybody have any ideas ?


This is in the FAQ, though the FAQ might refer to a different function
in <math.h>. (abs is declared in <stdlib.h>, BTW.)

--
Eric Amick
Columbia, MD
Nov 14 '05 #3
bq
"LeTubs" <dl*****@yahoonospam.co.uk> wrote in message news:<dpLCc.302$da5.207@newsfe2-win>...
now the funny thing is that I use the function abs
which is the math.h function.


If you want ablsoute values of floating point numbers use fabs(), not abs().
e.g. abs(5.3) is 5, the integer 5, and when you do
double x;
x = abs(5.3);
that integer get converted to double and you effectively get x = 5.0

bq
Nov 14 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: Frank Millman | last post by:
Hi all I was helping my niece with her trigonometry homework last night. Her calculator's batteries were flat, so I thought I would use Python's math module to calculate sin, cos, and tan. I...
0
by: Jussi Mononen | last post by:
Hi, I'm having problems to successfully execute the test scripts on a Compaq host ( OSF1 tr51bdev V5.1 2650 alpha ). Almost all tests end up with the following error message "PARI: *** ...
1
by: limelight | last post by:
I have discovered a math error in the .NET framework's Log function. It returns incorrect results for varying powers of 2 that depend on whether the program is run from within the IDE or from the...
17
by: cwdjrxyz | last post by:
Javascript has a very small math function list. However there is no reason that this list can not be extended greatly. Speed is not an issue, unless you nest complicated calculations several levels...
7
by: bravesplace | last post by:
Hello, I am using the folling funtion to round a number to a single digit on my form: function round1(num) { return Math.round(num*1)/1 }
110
by: Gregory Pietsch | last post by:
I'm writing a portable implementation of the C standard library for http://www.clc-wiki.net and I was wondering if someone could check the functions in math.h for sanity/portability/whatever. I'm...
11
by: Sambo | last post by:
I have the following module: ------------------------------- import math def ac_add_a_ph( amp1, ph1, amp2, ph2 ): amp3 = 0.0 ph3 = 0.0 ac1 = ( 0, 0j ) ac2 = ( 0, 0j )
0
by: kirby.urner | last post by:
Cyber-curricula have a leveling aspect, as kids nearer Katrina's epicenter tune in and bliss out on 'Warriors of the Net' (why wait for stupid big dummy textbooks to catch up?). They feel more...
4
by: =?Utf-8?B?UmVuZQ==?= | last post by:
Hello everyone I have a problem with Math.Round, it´s ocurring some strange: Math.Round(12.985) = 12.98, it´s wrong. It should be: 12.99 Why?? What is the problem? Help ME !!!!
15
by: bH | last post by:
Hi All, I have been looking at javascript drawing from this website : http://www.cwdjr.net/geometricDraw/pentagon_draw.html" and I am wondering why the author made it into two images : upper...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.