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

funny problem in C program !

hi im trying to run this simple program. any help shall be appreciated
..pls see error message.

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
int main()
{
double pic;
pic= 4.0 * atan(1.0);
printf("pi is = %f \n",pic);
}
error when i try to compile ...

[harshit@localhost ~]$ gcc harshit.c
/tmp/ccRf4QzM.o(.text+0x1b): In function `main':
: undefined reference to `atan'
collect2: ld returned 1 exit status

Nov 13 '05 #1
3 8815
Suri wrote:
hi im trying to run this simple program. any help shall be appreciated
..pls see error message.

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
int main()
{
double pic;
pic= 4.0 * atan(1.0);
printf("pi is = %f \n",pic);
}
error when i try to compile ...

[harshit@localhost ~]$ gcc harshit.c
/tmp/ccRf4QzM.o(.text+0x1b): In function `main':
: undefined reference to `atan'
collect2: ld returned 1 exit status

^^^^^^^^^^^^^^^^^^^^^^^^^

Suri...

Not a compile problem. ld can't resolve atan() - try:

gcc -lm harshit.c

so that ld will know to search the math library.

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

--
Morris Dovey
West Des Moines, Iowa USA
C links at http://www.iedu.com/c
Read my lips: The apple doesn't fall very far from the tree.

Nov 13 '05 #2
Suri <hs***@usc.edu> writes:
Subject: funny problem in C program !


Yeah, it's so funny there's a FAQ for it. Please read the FAQ.
Nov 13 '05 #3
Suri wrote:
hi im trying to run this simple program. any help shall be appreciated
.pls see error message.

I can see 2 C-related problems :
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
int main()
should be int main(void) or int main(int argc, char **argv)
{
double pic;
pic= 4.0 * atan(1.0);
printf("pi is = %f \n",pic);
main must return an int. Default is EXIT_SUCCESS (defined in stdlib.h).
}
error when i try to compile ...
The compiler should at least warn you that it reaches the end of a
non-void function. If it doesn't, RTM and learn how to raise warning level.

<ot> for gcc, -Wall -ansi -pedantic should be a good start </ot>
[harshit@localhost ~]$ gcc harshit.c
/tmp/ccRf4QzM.o(.text+0x1b): In function `main':
: undefined reference to `atan'
collect2: ld returned 1 exit status


This is not a problem with the C language, it's a problem with your
linker. And it's a FAQ. RTF !-)

Bruno

Nov 13 '05 #4

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

Similar topics

1
by: eScrewDotCom | last post by:
eScrew Welcome to eScrew! eScrew is eScrew and this is eScrew story. eScrew will tell you eScrew story if you promise eScrew to consider eScrew story as joke. eScrew story is very funny. eScrew...
8
by: eScrewDotCom | last post by:
eScrew Welcome to eScrew! eScrew is eScrew and this is eScrew story. eScrew will tell you eScrew story if you promise eScrew to consider eScrew story as joke. eScrew story is very funny. eScrew...
5
by: Matt | last post by:
I wrote the tcp socket client-server program that the server will echo the message received from the client. In client program: char sendBuf; while(1) { cout << "Enter message:";...
5
by: eScrewDotCom | last post by:
www.eScrew.com eScrew Welcome to eScrew! eScrew is eScrew and this is eScrew story. eScrew will tell you eScrew story if you promise eScrew to consider eScrew story as joke. eScrew story is...
0
by: eScrewDotCom | last post by:
eScrew Welcome to eScrew! eScrew is eScrew and this is eScrew story. eScrew will tell you eScrew story if you promise eScrew to consider eScrew story as joke. eScrew story is very funny. eScrew...
10
by: Markus Svilans | last post by:
Hi, I have a weird problem in a virtual method. The original method code raises an access violation when it is run. The solution to the problem is to declare a dummy integer inside the virtual...
4
cartpauj
by: cartpauj | last post by:
I have kind of a funny situation. I recently downoaded a .cgi maillist program for my website but in order to activate the script it requires me to place a line of code on my page like this: <img...
3
by: sophie_newbie | last post by:
Hi, I want to store python text strings that characters like "é" "Č" in a mysql varchar text field. Now my problem is that mysql does not seem to accept these characters. I'm wondering if there...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: 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:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.