Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > can not figure out the problem

Reply
Thread Tools

can not figure out the problem

 
 
yezi
Guest
Posts: n/a
 
      11-28-2005
HI, ALL:

I can not figure out the problem with compiling.

the message is "
/tmp/ccAxyQSj.o(.text+0x275): In function `main':
: undefined reference to `sqrt'
collect2: ld returned 1 exit status
"

At first I thought is because the gcc "math.h" do not have the function
: then I type "gcc --version "

gcc (GCC) 3.3.2 20031022 (Red Hat Linux 3.3.2-1)
Copyright (C) 2003 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is
NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.

Then I use "man sqrt " in my system, it works.

My question : why the compiler failure?

THanks


bin YE

 
Reply With Quote
 
 
 
 
David Resnick
Guest
Posts: n/a
 
      11-28-2005

yezi wrote:
> HI, ALL:
>
> I can not figure out the problem with compiling.
>
> the message is "
> /tmp/ccAxyQSj.o(.text+0x275): In function `main':
> : undefined reference to `sqrt'
> collect2: ld returned 1 exit status
> "
>
> At first I thought is because the gcc "math.h" do not have the function
> : then I type "gcc --version "
>
> gcc (GCC) 3.3.2 20031022 (Red Hat Linux 3.3.2-1)
> Copyright (C) 2003 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions. There is
> NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
> PURPOSE.
>
> Then I use "man sqrt " in my system, it works.
>
> My question : why the compiler failure?
>
> THanks
>
>
> bin YE


http://www.eskimo.com/~scs/C-faq/q14.3.html

-David

 
Reply With Quote
 
 
 
 
yezi
Guest
Posts: n/a
 
      11-28-2005
many thanks , quite right~

 
Reply With Quote
 
Flash Gordon
Guest
Posts: n/a
 
      11-28-2005
yezi wrote:
> HI, ALL:
>
> I can not figure out the problem with compiling.
>
> the message is "
> /tmp/ccAxyQSj.o(.text+0x275): In function `main':
> : undefined reference to `sqrt'
> collect2: ld returned 1 exit status
> "
>
> At first I thought is because the gcc "math.h" do not have the function


<snip>

http://www.eskimo.com/~scs/C-faq/q14.3.html

I suggest you read the rest of the FAQ and the manuals for your compiler
& linker as well.
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.
 
Reply With Quote
 
Barry Schwarz
Guest
Posts: n/a
 
      11-29-2005
On 28 Nov 2005 13:45:32 -0800, "yezi" <(E-Mail Removed)> wrote:

>HI, ALL:
>
>I can not figure out the problem with compiling.
>
>the message is "
>/tmp/ccAxyQSj.o(.text+0x275): In function `main':
>: undefined reference to `sqrt'
>collect2: ld returned 1 exit status
>"


It is not a compiler failure. It is a linker failure. You need to
look at your documentation to determine how to tell the linker it
should use the math library to resolve function references.

>
>At first I thought is because the gcc "math.h" do not have the function


math.h is a header, not a library.

>: then I type "gcc --version "
>
>gcc (GCC) 3.3.2 20031022 (Red Hat Linux 3.3.2-1)
>Copyright (C) 2003 Free Software Foundation, Inc.
>This is free software; see the source for copying conditions. There is
>NO
>warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
>PURPOSE.
>
>Then I use "man sqrt " in my system, it works.
>
>My question : why the compiler failure?
>
>THanks
>
>
>bin YE



<<Remove the del for email>>
 
Reply With Quote
 
manu
Guest
Posts: n/a
 
      11-29-2005
one reason could be you didnot use the -lm clause while compiling.
try that if you haven't used that
gcc -lm <file.c>

this should solve your problem.

 
Reply With Quote
 
Keith Thompson
Guest
Posts: n/a
 
      11-29-2005
"manu" <(E-Mail Removed)> writes:
> one reason could be you didnot use the -lm clause while compiling.
> try that if you haven't used that
> gcc -lm <file.c>


One reason for what?

Please read <http://cfaj.freeshell.org/google/>.

--
Keith Thompson (The_Other_Keith) http://www.velocityreviews.com/forums/(E-Mail Removed) <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sorry for reposting - can not figure out... J Snaith ASP .Net 7 04-06-2010 01:13 AM
Can't figure out where SyntaxError: can not delete variable 'x'referenced in nested scope us coming from in python >=2.6 Albert Hopkins Python 3 12-10-2008 04:10 AM
I can not figure this vhdl logic out, help. logia VHDL 6 01-16-2006 03:03 PM
Printer problem-- can anyone figure this out? MB Computer Support 0 12-10-2003 11:19 PM
How do you figure out the LDAP://? ("Error authenticating. Error authenticating user. The specified domain either does not exist or could not be contacted") mrwoopey ASP .Net 3 06-30-2003 10:11 PM



Advertisments