LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-19-2008, 12:05 AM   #1
ufmale
Member
 
Registered: Feb 2007
Posts: 386

Rep: Reputation: 30
gcc link error (looking for log, floor function)


I got an error trying to link object files.
It is looking for different math function

gcc a.o b.o c.o -o myapp

undefined reference to `log'
undefined reference to `floor'
undefined reference to `cos'
undefined reference to `pow'


Is there any linker flag i need to build my app? COmpiling seems to work fine.
I am building it on fedora 7.
 
Old 07-19-2008, 12:52 AM   #2
komodo
Member
 
Registered: Jun 2008
Distribution: linux from scratch, Arch linux
Posts: 39

Rep: Reputation: 15
It looks as though you have no reference to math.h in your code. can you show us your preprocessor directives? If there is no reference to math.h, your calls to math functions like floor, pow, etc will not be swallowed by the linker. The compiler doesn't care about these things, it is the linker that makes the most problems.
 
Old 07-19-2008, 01:21 AM   #3
hariram_eee
LQ Newbie
 
Registered: Feb 2008
Posts: 2

Rep: Reputation: 0
Lightbulb

Try math.h else give a compiler option as -lmath
 
Old 07-19-2008, 09:21 AM   #4
ufmale
Member
 
Registered: Feb 2007
Posts: 386

Original Poster
Rep: Reputation: 30
Found the problem. it is -lm
 
  


Reply



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
having trouble with function 'floor' joel2001k Programming 6 06-25-2007 12:33 PM
function in a function in C compiling with gcc joel2001k Programming 5 06-23-2007 08:18 PM
how i get help from gcc about c function rajeshclt3 Linux - Software 2 10-12-2006 05:46 PM
Link error with mingw-gcc FLLinux Programming 0 07-28-2006 08:38 PM
red hat 9.0 gcc (ceil, floor and sqrt function errors) ?? gemini_shooter Linux - Enterprise 1 06-04-2005 04:23 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:34 AM.

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
Open Source Consulting | Domain Registration