undefined reference to `floor`

Joel Sherrill Joel.Sherrill at OARcorp.com
Mon Sep 16 11:59:33 UTC 2013


It is likely in the math library and you need to link with -lm

Sebastian Huber <sebastian.huber at embedded-brains.de> wrote:


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.
_______________________________________________
rtems-users mailing list
rtems-users at rtems.org
http://www.rtems.org/mailman/listinfo/rtems-users




More information about the users mailing list