undefined reference to `floor`

Sebastian Huber sebastian.huber at embedded-brains.de
Mon Sep 16 10:34:23 UTC 2013


On 2013-09-16 12:25, Peng Fan wrote:
> hi,
>
> I want to use math function in rtems, and add such a function:
>   77 int test(float a)
>   78 {
>   79     int b= floor(a);

The prototype is "double floor(double x)".  Please have a look at floorf().

>   80     return b;
>   81 }
> When compiling, it tells 'undefined reference to `floor'
> collect2: error: ld returned 1 exit status'
>
> I do not know how to resolve this. I tried to pass `-lm` to gcc, but still
> failed to link.

Can you please provide the full command line?


-- 
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax     : +49 89 189 47 41-09
E-Mail  : sebastian.huber at embedded-brains.de
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.



More information about the users mailing list