Trouble pulling in libm

John Wood jwood at
Fri Jan 14 14:03:24 UTC 2011

Here is the full line and I think the order is probably the problem.

powerpc/GNU C Linker building target APP_2
powerpc-rtems4.9-g++ --pipe -B../../../rtems/Install/powerpc-rtems4.9/dam/lib/ -specs bsp_specs -qrtems -fno-keep-inline-functions -mcpu=403 -Dppc405 -Ddam -Wl,-Map="./debug/"   -o "./debug/APP_2.elf" ./debug/obj/Init.o ./debug/obj/appqsst.o ./debug/obj/icmpping.o ./debug/obj/sdsn_tx.o   -lm -ltelnetd -lftpd -lptpd -lnfs  
../../../rtems/Install/powerpc-rtems4.9/dam/lib\librtemsbsp.a(main_qsst_wavecfg.o): In function `CalculateLFMCoefficients':
c:\Projects\digital_modules\dam\cfg\config1\rtems\build\powerpc-rtems4.9\c\dam\lib\libbsp\powerpc\dam/../../../../../../../../../../../../common_sw/rtems/c/src/lib/libbsp/powerpc/dam/../../powerpc/shared/plb46/qsst/main_qsst_wavecfg.c:293: undefined reference to `round'
collect2: ld returned 1 exit status
make: *** [debug/APP_2.elf] Error 1

-----Original Message-----
From: rtems-users-bounces at [mailto:rtems-users-bounces at] On Behalf Of Thomas Doerfler
Sent: Friday, January 14, 2011 2:49 AM
To: rtems-users at
Subject: Re: Trouble pulling in libm


I assume that your driver (which uses a libm function) is part of the
rtems library.

if I remember things right, ld will normally walk through the libraries
only once. So a library can provide library functions (like round() )
only for modules (and other lib functions) that have been pulled in
_before_ the library is listed on the ld command line.

So if you have the following order when linking:

.... application.o... ...-lm ... -lrtems ...

then libm will provide the math functions required for application.o,
but not for any reference in librtems.a . Changing the library order on
the command line would be _one_ way to fix that.

I am sure Ralf can give you hints how to fix this properly, but
providing as much information as possible is vital for this. So please
cut and post the actual error messages and the command line of the
linker that lead to the errors.



Am 14.01.2011 06:43, John Wood wrote:
> If I call round only in my driver I get the previous linker error.
> If I add the following code to one of my application files.
>   double test;
>   double value = 0.5;
>   test = round(value);
> The linker error goes away.  Its seems like there is something going on calling a libm function in the rtems code and not calling it in the app.
> I have to call the specific function and not just another libm function, if I replace the round in the above code with sqrt for example I get the linker error again.
> I don’t have my hardware so I can't tell if the function is actually linking correctly.  I'll test this tomorrow.  Short term I can put the code in my app but ideally it belongs with the driver.
> -----Original Message-----
> From: Ralf Corsepius [mailto:ralf.corsepius at] 
> Sent: Friday, January 14, 2011 12:32 AM
> To: John Wood
> Cc: Andrei Chichak; Ralf Corsepius; RTEMS List
> Subject: Re: Trouble pulling in libm
> On 01/14/2011 06:17 AM, John Wood wrote:
>> I assumed that and actually am pulling in several libraries successfully myself so I did not expect this issue.
>> I am trying to refine things in terms of my issues.  I noticed on closer inspection that the math.h file inclusion does not appear quite right since it says the round function definition is implicitly defined.
> To getting started, it would be sufficient to see the actual error message.
> Ralf
> PS.: I am asking, because I know about several issues with libm in 
> rtems4.10's and rtems4.11's newlib, which some of which have been 
> addressed, but have not yet been addressed in rtems4.9's newlib.
> These issues typically show as link errors with the linker complaining 
> about missing symbols from deep inside of newlib.
> _______________________________________________
> rtems-users mailing list
> rtems-users at


embedded brains GmbH
Thomas Doerfler        Obere Lagerstrasse 30
D-82178 Puchheim       Germany
email: Thomas.Doerfler at
Phone: +49-89-18908079-2
Fax:   +49-89-18908079-9
PGP:   Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.
rtems-users mailing list
rtems-users at

More information about the users mailing list