LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-10-2004, 03:21 PM   #1
jaggu
LQ Newbie
 
Registered: Jul 2003
Posts: 5

Rep: Reputation: 0
Need help with a c program


I am trying with a simple c program that uses a pow(op1, op2) function.
gcc says "undefined reference to pow" during linking.
"gcc -c myprog.c" gives no error messages (even when i didnt include math.h :-S ),
but gave the above error message on 'pow' when i gave "gcc myprog.c"

"man pow" says function 'pow' is with the 'math.h'.
But giving/not giving "#include <math.h>" have no effect with gcc.
Then i tried using some other functions with the math.h like log, exp, etc,
and i got the same error message "undefined reference to ___" with those functions too.
I checked the /usr/include directory and found math.h there. [I dint know what is its corresponding lib file]

I am with a redhat 8.0 linux box.
I also tried uninstalling and then re-installing all the development tools using the GUI package manager,
but no effect.:-(


 
Old 02-10-2004, 03:23 PM   #2
jtshaw
Senior Member
 
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Blog Entries: 1

Rep: Reputation: 67
Try doing this = "gcc -Wall -o myprog -lm myprog.c".

-Wall = shows all warnings
-o myprog = sets the name of the binary created (otherwise it would be a.out)
-lm = links the math library in

And from now on put programming related questions in the programming forum.

Last edited by jtshaw; 02-10-2004 at 03:25 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
sms program and database in linux web program in windows.. does not see each other.. keikun_naruchan Programming 0 07-06-2005 02:40 AM
Total recovery: Which program? ghost4linux, YaST2? Best drive imaging program? lagu2653 Linux - Software 1 06-20-2005 02:44 PM
Stop java program(threaded program..should end cleanly) rmanocha Programming 4 11-09-2004 10:36 AM
Gtk-Warning but program still works... I close konsole, program closes Laptop2250 Linux - Software 2 11-15-2003 12:18 AM
Viewing program messages when program isn't run from command line? Locura Linux - Software 1 09-27-2003 09:19 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:24 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration