I am having trouble linking against an external library, MY_LIB.a
.
The following is invoked from the makefile created by mbed.org compiler, and with the addition of my link to MY_LIB.a
path.
arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -Wl,--gc-sections --specs=nano.specs
-u _printf_float -u _scanf_float -T./mbed/TARGET_LPC1768/TOOLCHAIN_GCC_ARM/LPC1768.ld
-L./mbed/TARGET_LPC1768/TOOLCHAIN_GCC_ARM -o MyProg.elf main.o mbed/TARGET_LPC1768
/TOOLCHAIN_GCC_ARM/cmsis_nvic.o mbed/TARGET_LPC1768/TOOLCHAIN_GCC_ARM/system_LPC17xx.o
mbed/TARGET_LPC1768/TOOLCHAIN_GCC_ARM/startup_LPC17xx.o mbed/TARGET_LPC1768
/TOOLCHAIN_GCC_ARM/board.o mbed/TARGET_LPC1768/TOOLCHAIN_GCC_ARM/retarget.o
-lstdc++ -lsupc++ -lm -lc -lgcc -lnosys -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys
-L/usr/local/lib/MY_LIB.a
main.o: In function `main':
And then I get undefined reference to <function>
errors for every function defined in MY_LIB
.
My understanding was that MY_LIB.a
just needed to be linked after main.o
which uses it.
I also tried linking (immediately) after -o MyProg.elf main.o
, but then I get could not read symbols: File in wrong format
.
What is the correct way to link this library? Does it need to be linked in the previous step to be listed here in.. the correct format? How is that done?