473,396 Members | 2,003 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,396 software developers and data experts.

can not figure out the problem

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

Nov 28 '05 #1
6 1603

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

Nov 28 '05 #2
many thanks , quite right~

Nov 28 '05 #3
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.
Nov 28 '05 #4
On 28 Nov 2005 13:45:32 -0800, "yezi" <ye*****@hotmail.com> 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>>
Nov 29 '05 #5
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.

Nov 29 '05 #6
"manu" <ma*************@gmail.com> 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) ks***@mib.org <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.
Nov 29 '05 #7

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

Similar topics

10
by: Jeff | last post by:
Hello everybody, I just have a little problem, and I just can't figure out what it is: $ cat test.c #include <stdio.h> int main (void) { char* s = "CAT";
3
by: ken | last post by:
Hello, I can't figure out how to solve this problem. I modified the timer example given in the help section. It increments a count every 3 millisecond in order to simulate a tank being filled with...
3
by: Brian Blais | last post by:
Hello, I have an odd kind of Heisenbug in what looks like a pretty simple program. The program is a progress bar code I got at the Python Cookbook: ...
2
by: g35rider | last post by:
Hi, I have the following code that is giving this error, I cant simplify the code, I was just testing some theory for something we are doing and was getting an issue here. Please someone point out...
0
by: hector | last post by:
Hi all, Need i simple example on how print/preview data from a database. I already have some code but I am lost because the preview does not create multiple pages and only shows the first page...
0
by: Steve | last post by:
I have a gridview which uses an objectdatasource for its select and delete. The delete command uses the function below. The delete itself works but the extra logic which requires parameters...
0
by: Frank | last post by:
Hi, I use rpy to plot functions and have the following problem. When I execute the following code line by line (start python and then execute line by line) the resulting figure looks as it...
2
by: dmitrey | last post by:
Hi all, here is a question already mentioned below, and I'm also interested in that one very much. unfortunatly, I can't write anything to matplotlib mailing lists because I constantly get server...
1
by: mcjason | last post by:
Say pieces on a board, make each a pair with another piece. like... |55|33|66| |44|66|55| |33|44|22| |22|11|11| so figure out how a piece can move.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.