GIDForums  

Go Back   GIDForums > Computer Programming Forums > C Programming Language
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 04-Jul-2005, 04:30
tnethaji tnethaji is offline
New Member
 
Join Date: Jul 2005
Posts: 3
tnethaji is on a distinguished road
Unhappy

Math function errors


Hi,
I have a big program wiht lots of subroutines. This has most of the math functions in it. But, I couldn't compile the program which was compiled and ran well in redhat linux 7.3 and alpha unix operating systems.

now i have redhat linux 9.0

i wrote a simple code to see where the problem is,

the code:

CPP / C++ / C Code:
#include "math.h"
main()
{
 float x,y;

 for(x=1;x<=5;x++)
    printf("x = %.2f\n",log(x));
}

when i compile this

%cc mathfn.c
/tmp/ccREyveT.o(.text+0x3c): In function `main':
: undefined reference to `log'
collect2: ld returned 1 exit status

i get his error. i checked ld and used various options, but couldn't figure out what is going on. Same error i get for all other math functions.

any help/suggestions?????

thanks in advance
netha
Last edited by LuciWiz : 04-Jul-2005 at 12:21. Reason: Please insert your C code between [c] & [/c] tags
  #2  
Old 04-Jul-2005, 14:22
WaltP's Avatar
WaltP WaltP is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Midwest US
Posts: 3,258
WaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to all
What happened? Forgot the code tags, eh?

Suggestions:
1) verify log() is defined in math.h -- should be no problem
2) Does the math library have to be specified to be linked into the program? Sometimes compilers don't automatically link some libs and they have to be explicitly specified.

Maybe this post will help... ;-)
__________________

Got a cough? Go home tonight and eat a whole box of Ex-Lax. Tomorrow, you'll be afraid to cough.
-- Pearl Williams
 
 

Recent GIDBlogWriting a book by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[Include] Doubly-linked List dsmith C Programming Language 6 14-Apr-2006 14:12
[Tutorial] Function Pointers aaroncohn C++ Forum 4 17-Feb-2006 12:33
[GIM] gim.h dsmith C Programming Language 0 18-Jan-2005 09:48
Revising Script style ?????? pepee MySQL / PHP Forum 4 14-Apr-2004 05:59

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 04:04.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.