problem with math.h

Hello,

I have a problem with some code to compile.


The program is:
Code:
#include <math.h>

int main(void)
{
        double e=expl(2);
        //logl(2);
        return 1;
}

The error/output I get is:
Code:
test.c: In function 'main':
test.c:5: warning: incompatible implicit declaration of built-in function 'expl'
/var/tmp//ccOg5PBt.o(.text+0x20): In function `main':
: undefined reference to `expl'
Code:
find /usr/src/ -name "math.h"
/usr/src/contrib/libstdc++/include/c_compatibility/math.h
/usr/src/contrib/libstdc++/include/tr1/math.h
/usr/src/lib/msun/src/math.h"]

I am wondering whether the warning: incompatible implicit declaration of built-in function 'expl' is directly related to the problem.
Sorry I am really not an expert,
Thanks,
plichel
 
Last edited by a moderator:
As I see now the error has to to with linking not compiling.
Furhtermore it turned out that it isnt necessary to inlclude math.h
I tried this command
gcc test.c -lm
to the code above without the include header and got the same error.
 
plichel said:
...
The program is:
Code:
#include <math.h>

int main(void)
{
        double e=expl(2);
        //logl(2);
        return 1;
}

expl() is the long double version of the exponential function. FreeBSD supports long doubles, however, some functions are missing in libm.

On my FreeBSD 8.3-RELEASE-p3 (i386), libm is indeed missing expl(), and in /usr/include/math.h, it is conditionally deactivated.

Since you anyway try to assign the functional result to a double value, you simply could get away with the double version of the exponential function, i.e. exp().

Best regards

Rolf
 
Back
Top