Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 14:52 Go to next message
Nelio is currently offline NelioFriend
Messages: 2
Registered: April 2010
Junior Member
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 19:08 Go to previous messageGo to next message
Nick Schweyer is currently offline Nick SchweyerFriend
Messages: 175
Registered: July 2009
Senior Member
I had the same problem:
you have to tell the linker to use the math library by setting -m


Niko

Eclipse-CDT Version: 2019-12 (4.14.0), Win10 64bit
Re: math functions not working on Linux [message #525841 is a reply to message #524957] Wed, 07 April 2010 23:37 Go to previous messageGo to next message
Nelio is currently offline NelioFriend
Messages: 2
Registered: April 2010
Junior Member
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 16:34 Go to previous messageGo to next message
Don Porges is currently offline Don PorgesFriend
Messages: 13
Registered: July 2009
Junior Member
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] Thu, 23 August 2012 01:10 Go to previous messageGo to next message
Esdras Adriano is currently offline Esdras AdrianoFriend
Messages: 2
Registered: August 2012
Location: Brasil
Junior Member
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: Thu, 23 August 2012 01:11]

Report message to a moderator

Re: math functions not working on Linux [message #903366 is a reply to message #524941] Thu, 23 August 2012 11:24 Go to previous message
Esdras Adriano is currently offline Esdras AdrianoFriend
Messages: 2
Registered: August 2012
Location: Brasil
Junior Member
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: Wed Oct 16 01:38:10 GMT 2024

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

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

Back to the top