← Back to team overview

ubuntuforums-unanswered team mailing list archive

[Question #77587]: C compiler does not recognize the EXP function even though the program includes math.h

 

New question #77587 on Ubuntu:
https://answers.launchpad.net/ubuntu/+question/77587

My program is:
#include <math.h>
#include <stdio.h>

main ()
{
double x, y;
x=0.16;
y=exp(x);
printf("x=%f y=%f\n", x, y);
}

But compilation fails:
CMD:gcc checkExp.c
/tmp/ccEhiLY7.o: In function `main':
checkExp.c:(.text+0x21): undefined reference to `exp'
collect2: ld returned 1 exit status

The same happens with the Logarithm function, and trigonometric functions (sin, cos, etc.)
In addition, the Absolute-Value function (abs) does pass compilation, but running the program gives garbage:
CMD:a.out
x=-0.160000 y=1202590843.000000

I have checked that I do have the file /usr/include/math.h
Actually I have run the program while including ALL header files of /usr/include but still without success -
the compiler does not recognize these mathematical functions.

What do I have to do in order to have the C-compiler recognize these math functions?

Thank you, Gidi

-- 
You received this question notification because you are a member of UF
Unanswered Posts Team, which is an answer contact for Ubuntu.