LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 10-05-2010, 12:52 PM   #1
gerry_bertier
LQ Newbie
 
Registered: Oct 2010
Posts: 2

Rep: Reputation: 0
problem regarding executing c program in ubuntu


Hi,

i am a newbie in linux.
i have a c program which runs on linux....so i installed ubuntu 10.04 version on my system.

i tried to compile this program 'mygen.c' (using gcc -o mygen.c) but i was given some errors -

mygen.c.text+0x4fe): undefined reference to `exp'
mygen.c.text+0x569): undefined reference to `sqrt'
mygen.c.text+0x57a): undefined reference to `log'
mygen.c.text+0x5b9): undefined reference to `tan'
mygen.c.text+0x5e9): undefined reference to `floor'
mygen.c.text+0x631): undefined reference to `exp'
collect2: ld returned 1 exit status

i thought that maybe 'math.h' is missing.
so, i checked the folder /usr/include and it do contains the file 'math.h'.
but this math.h do not have anything related to 'exp','sqrt' or some other math functions.

i downloaded a new header file 'math.h' from internet.
i tried to save it in the folder /usr/include but i could not.
i don't have the permission to paste the header file in /usr/include.
i am the administrator then why don't i have the required permission to paste that file ?
i tried with the commands to change the permission for this folder...but met no success.

i would be more than happy if u could sort out my problem.

thanx in advace.
 
Old 10-05-2010, 01:01 PM   #2
GrapefruiTgirl
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556
I believe the header file you're looking for is tgmath.h and that it *might* not be on your Ubuntu machine by default. You need to install at least one additional package of stuff, before you can compile. The following command should help:
Code:
sudo apt-get install build-essential
EDIT On second look, I may have spoken before reading thoroughly; disregard this and try the next post first.

Last edited by GrapefruiTgirl; 10-05-2010 at 01:22 PM.
 
1 members found this post helpful.
Old 10-05-2010, 01:01 PM   #3
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
hi, welcome to LQ!

That's a linker problem, not a compiler one. Just bind
the math library to your executable.

Code:
-lm
Cheers,
Tink

Last edited by Tinkster; 10-05-2010 at 01:02 PM.
 
1 members found this post helpful.
Old 10-05-2010, 01:07 PM   #4
GrapefruiTgirl
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556
Thanks Tink - So are the headers are all there by default on Ubuntu? I thought they were not included?
 
Old 10-05-2010, 01:59 PM   #5
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Quote:
Originally Posted by GrapefruiTgirl View Post
Thanks Tink - So are the headers are all there by default on Ubuntu? I thought they were not included?
Don't know about Ubunut and its defaults - but if it were
a header problem he'd see compiler errors, not linker ones.
"Undefined reference" is clearly a linker error.



Cheers,
Tink
 
Old 10-05-2010, 02:14 PM   #6
GrapefruiTgirl
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556
Yes, OP's post is similar to an earlier post and I wasn't paying attention when I read it. I'm going back to sleep now.
 
Old 10-15-2010, 07:44 AM   #7
gerry_bertier
LQ Newbie
 
Registered: Oct 2010
Posts: 2

Original Poster
Rep: Reputation: 0
thank you everyone....
my problem is solved....
 
  


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
Help Executing C Program From Java! (Ubuntu) penguinGirl Linux - Software 2 04-18-2010 02:03 PM
Executing a program in c daYz Programming 2 07-27-2007 03:34 PM
Executing a program on start up andrewthk Debian 3 03-23-2006 12:49 AM
executing a program in new terminal? kashifbilal Programming 7 04-26-2004 04:52 AM
Servlets executing a C program. webee Programming 1 02-04-2003 05:19 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:01 PM.

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