Skip to main content



      Home
Home » Language IDEs » C / C++ IDE (CDT) » math functions not working on Linux(math functions not working on Linux)
math functions not working on Linux [message #524941] Sun, 04 April 2010 10:52 Go to next message
Eclipse UserFriend
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 #524957 is a reply to message #524941] Sun, 04 April 2010 15:08 Go to previous messageGo to next message
Eclipse UserFriend
I had the same problem:
you have to tell the linker to use the math library by setting -m
Re: math functions not working on Linux [message #525841 is a reply to message #524957] Wed, 07 April 2010 19:37 Go to previous messageGo to next message
Eclipse UserFriend
I did what you said, but now a new error is appearing. Suppose "testproj" is the project name:

Errors (1 item)
unrecognised emulation mode: -otestproj

Location: line 0

Type: C/C++ Problem
Re: math functions not working on Linux [message #526091 is a reply to message #525841] Thu, 08 April 2010 12:34 Go to previous messageGo to next message
Eclipse UserFriend
He made a typo: the flag you want is -lm not -m. Although you can do with that just by entering "m" in the Libraries list of the Linker settings.
Re: math functions not working on Linux [message #903299 is a reply to message #526091] Wed, 22 August 2012 21:10 Go to previous messageGo to next message
Eclipse UserFriend
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.

[Updated on: Wed, 22 August 2012 21:11] by Moderator

Re: math functions not working on Linux [message #903366 is a reply to message #524941] Thu, 23 August 2012 07:24 Go to previous message
Eclipse UserFriend
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.
Previous Topic:Invalid project paths in multi-platform project
Next Topic:Armadillo library and Eclipse
Goto Forum:
  


Current Time: Tue Jul 08 02:08:08 EDT 2025

Powered by FUDForum. Page generated in 0.07552 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top