# problem with math.h



## plichel (Jul 11, 2012)

Hello,

I have a problem with some code to compile.


The program is:

```
#include <math.h>

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

The error/output I get is:

```
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'
```


```
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


----------



## plichel (Jul 11, 2012)

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.


----------



## Anonymous (Jul 11, 2012)

plichel said:
			
		

> ...
> The program is:
> 
> ```
> ...



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


----------

