Using sqrt() in RTEMS Task

Joel Sherrill joel.sherrill at
Thu Jul 24 13:06:03 UTC 2008

Christian Poessinger wrote:
> Hello,
> is it possible to use the sqrt() call in RTEMS tasks, or is this function
> only available to POSIX tasks? I tried including the math.h and appending
> a -lm to my LIBS var in the Makefile but I always receive the error:
> o-optimize/lat.o: In function `sTask':
> /home/source/RTEMS/lat/lat.c:80: undefined reference to `sqrt'
> collect2: ld returned 1 exit status
> make: *** [o-optimize/lat.exe] Error 1
> It looks like to me that math.h and libm.a could not be found.
This doesn't mean math.h wasn't found.  That would have
been a warning or error during compilation of lat.c to lat.o.

This means you didn't link against -lm when linking the
program just like if you were compiling a native program.

The only thing to note on RTEMS is that each Classic API
task may optionally have the FPU enabled and have an FP
context.  Include the attribute RTEMS_FLOATING_POINT
on the task create call for all tasks doing FPU operations.
> Thanks.
> _______________________________________________
> rtems-users mailing list
> rtems-users at

Joel Sherrill, Ph.D.             Director of Research & Development
joel.sherrill at        On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
   Support Available             (256) 722-9985

More information about the users mailing list