Open Kyran-C opened 6 years ago
Looks like the fix is to change the order in the linker script, to put libm first:
At this line: https://github.com/dvhdr/launchpad-pro/blob/master/stm32_flash.ld#L137
change it from:
/DISCARD/ :
{
libc.a ( * )
libm.a ( * )
libgcc.a ( * )
}
to:
/DISCARD/ :
{
libm.a ( * )
libc.a ( * )
libgcc.a ( * )
}
I think this was prematurely instructing the linker to remove references to __errno
from libc
, which in turn breaks pow
.
Referencing pow
etc. adds about 13KB to the size of the binary produced, so if you have a large app that might be a problem!
Tried that, still not working. I was getting the errors initially about __errno, but now it's only saying undefined reference to 'pow'
. I did a make clean, reinstalled the VM, overwrote the makefile with the original to make sure there's no changes... Still the same linker error. I've tried putting -lm in the linker flags and few other places and it didn't work. Tried explicitly adding the paths to libm.a and math.h in the makefile LIB and INCLUDES variables. Maybe I'm pointing it at the wrong version, but that didn't help either. Based on the compiler docs, I assume it should be /usr/local/gcc-arm-none-eabi-4_8-2014q3/arm-none-eabi/lib/armv7-m/
I expected it to lookup and link the proper lib since it has the -mcpu=cortex-m3
linker flag, but it seems like the -lm flag isn't working.
Must confess I'm developing locally on my Mac these days, against the v5 ARM tools: https://launchpad.net/gcc-arm-embedded/5.0/5-2016-q3-update
Are you running on Vagrant, Docker or locally?
I'm trying to use pow and running into link errors (undefined reference to 'pow'). What flags do I need to change to get floating point math working?