Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Tue 30 Sep 2014, 02:11
All times are UTC - 4
 Forum index » House Training » Users ( For the regulars )
problem with gcc compiler and math functions
Moderators: Flash, Ian, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [4 Posts]  
Author Message
gemera

Joined: 17 Feb 2012
Posts: 14

PostPosted: Thu 04 Oct 2012, 12:59    Post subject:  problem with gcc compiler and math functions  

I've compiled tons of c programs in Puppy using Geany and the gcc compiler without any problems.

But for the first time I have used one of the math functions defined in the <math.h> header and get an error which I just can't solve.

Since I am learning c for both Windows and Linux I know the program works in the gcc compiler in Codeblocks for Windows.

Code:


#include <math.h>
#include <stdio.h>

int main(void)
{
      double x,y;

      x = 5;

      y = sqrt(x);

      return 0;
}



the error message is

Code:


/tmp/ccr0Yo3k.o: In function `main':
/root/test.c:11:undefined reference to `sqrt'
collect2: ld returned 1 exit status
make: ***[all] Error 1



btw I can use ANY of the math functions and get the same error.
Back to top
View user's profile Send private message 
SFR


Joined: 26 Oct 2011
Posts: 1072

PostPosted: Thu 04 Oct 2012, 13:41    Post subject:  

Hey Gemera

Although I don't know C at all (high time to learn it at last...), but I think this will shed some light on the problem:
https://bbs.archlinux.org/viewtopic.php?id=47461

I've compiled your example with -lm and it seems to be ok...

Greetings!

_________________
[O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource
Omnia mea mecum porto.
Back to top
View user's profile Send private message 
gemera

Joined: 17 Feb 2012
Posts: 14

PostPosted: Thu 04 Oct 2012, 14:13    Post subject:  

thanks for the heads up sdk.

really appreciated!
Back to top
View user's profile Send private message 
Karl Godt


Joined: 20 Jun 2010
Posts: 3972
Location: Kiel,Germany

PostPosted: Thu 04 Oct 2012, 17:52    Post subject:  

This is with newer gcc i think . Had similar on Puppy Precise .
_________________
«Give me GUI or Death» -- I give you [[Xx]term[inal]] [[Cc]on[s][ole]] .
Macpup user since 2010 on full installations.
People who want problems with Puppy boot frugal Razz
Back to top
View user's profile Send private message Visit poster's website 
Display posts from previous:   Sort by:   
Page 1 of 1 [4 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » House Training » Users ( For the regulars )
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0448s ][ Queries: 12 (0.0042s) ][ GZIP on ]