Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 02-10-2004, 02:21 PM   #1
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, 02:23 PM   #2
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 02:25 PM.


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 01:40 AM
Total recovery: Which program? ghost4linux, YaST2? Best drive imaging program? lagu2653 Linux - Software 1 06-20-2005 01:44 PM
Stop java program(threaded program..should end cleanly) rmanocha Programming 4 11-09-2004 09:36 AM
Gtk-Warning but program still works... I close konsole, program closes Laptop2250 Linux - Software 2 11-14-2003 11:18 PM
Viewing program messages when program isn't run from command line? Locura Linux - Software 1 09-27-2003 08:19 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:19 PM.

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