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. |
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 |
hi, welcome to LQ!
That's a linker problem, not a compiler one. Just bind the math library to your executable. Code:
-lm Tink |
Thanks Tink :) - So are the headers are all there by default on Ubuntu? I thought they were not included?
|
Quote:
a header problem he'd see compiler errors, not linker ones. "Undefined reference" is clearly a linker error. Cheers, Tink |
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. :o
|
thank you everyone....
my problem is solved....:) |
All times are GMT -5. The time now is 02:03 AM. |