Fedora Linux Support Community & Resources Center
  #1  
Old 6th January 2005, 02:00 PM
pafLaXe Offline
Registered User
 
Join Date: Jan 2005
Posts: 6
problem with gcc/glibc (?)

hello all

i run a fedora core 3 newly installed
I'm new to gcc, i used to compile my program under borland c/c++ until yet.
i have a problem compiling my programs with gcc.

look at this example :

#include <math.h>

int main(void) {
float toto = 3.23;
float titi;

titi = floorf(toto);
}

when i try to compile it with :

$ gcc -o test test.c

i get :

/tmp/ccGtZYgC.o(.text+0x2b): In function `main':
: undefined reference to `floorf'
collect2: ld returned 1 exit status

and this is just an example, i tried with several other headers and i get this type of error with whatever function i use...

can someone help me ?
thx !!

vince
Reply With Quote
  #2  
Old 6th January 2005, 04:07 PM
tashirosgt Offline
Registered User
 
Join Date: Aug 2004
Posts: 3,855
Try
gcc -o test tes.c -lm
You need a command like -lxyz to link a library named libxyz. The math functions are in libm, so you need the -lm option.
Getting programs to compile and link requires almost as much study as learning programming. After you have done some simple ones from the command line, you'll want to learn the fundamentals of the gnu make utility (not a simple thing either).
__________________
"Never let the task you are trying to accomplish distract you from the study of computers."
Reply With Quote
  #3  
Old 6th January 2005, 04:18 PM
pafLaXe Offline
Registered User
 
Join Date: Jan 2005
Posts: 6
thanks ! Sure i will (try) to learn gnu make... one day...
Reply With Quote
  #4  
Old 6th January 2005, 05:40 PM
PompeyBlue's Avatar
PompeyBlue Offline
Registered User
 
Join Date: Jun 2004
Location: Portsmouth, UK
Posts: 444
Don't forget

If you want

float x = 3.23;

then you should type

float x = 3.23f;

Otherwise the compiler casts your float to a "double float" which is generally slower on most architectures to compute. Adding the 'f' suffix ensures it's a true float (32 bits) and therefore runs much faster.
Reply With Quote
Reply

Tags
gcc or glibc, problem

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem updating glibc-common/glibc maladeus Using Fedora 0 28th August 2007 07:23 PM
"yum install glibc-devel" = Error: glibc-common conflicts with glibc < 2.3.6 nat101l Using Fedora 22 10th November 2005 06:16 PM
roll back from glibc-2.3.3 to glibc-2.3.2 ?? dylpower Using Fedora 1 22nd October 2004 10:26 PM


Current GMT-time: 04:55 (Tuesday, 21-05-2013)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat