math functions not working on Linux [message #524941] |
Sun, 04 April 2010 10:52  |
Eclipse User |
|
|
|
Hello,
I'm trying to test simple programs with math functions (sqrt, pow, exp, etc.) in Eclipse for C/C++ in a Ubuntu S.O. A simple program like this doesn't work:
#include <stdio.h>
#include <math.h>
int main () {
double param, result;
param = 5.0;
result = exp (param);
printf ("The exponential value of %lf is %lf.\n", param, result );
return 0;
}
Compiler says something like undefined reference to `exp'
Se same test works perfectly in Windows, but not in Ubuntu. What am I missing?
Another information: if I use exp(5.0) instead of exp(param), the program works!!
Thank you
Nelio
|
|
|
|
|
|
|
Re: math functions not working on Linux [message #903366 is a reply to message #524941] |
Thu, 23 August 2012 07:24  |
Eclipse User |
|
|
|
Hello,
I also had the same problem as you guys and I'm using the Eclipse version 3.7.2 on ubuntu 12.04. I solved the problem by entering the command -lm in:
Project>> Properties >> Cross GCC linker>> Miscellaneous >>Other objects.
bye and enjoy.
Esdras.
|
|
|
Powered by
FUDForum. Page generated in 0.07552 seconds