adamheinrich / cm-makefile

Makefile template for Cortex-M projects using the GCC ARM Embedded toolchain.
GNU Lesser General Public License v3.0
47 stars 6 forks source link

Linking math and c++ #1

Closed johschmitz closed 6 years ago

johschmitz commented 6 years ago

I am trying to link against CMSIS math library to use an fft but without success. Furthermore I need to compile and link an extra c++ library for nrf24 modules but it seems your makefile doesn't support c++. I was trying various options From Atollic TrueSTUDIO I see -Wl,--start-group -lc -lm -lcstd++ -lsupc++ -Wl,--end-group I tried to add this to the LDFLAGS in config.mk but without success. Can you provide some hints what to do? Do I need nano.specs for m4?

adamheinrich commented 6 years ago

Hi, yes, C++ is not supported. It should be easy to add it if needed: You basically just need to add rules to compile your C++ files similar to the existing C rules and use g++ instead of gcc to link the whole binary. It might be also necessary to change LDFLAGS. I'm not a big fan of C++ but I can try to add it if you really want ;)

For the CMSIS math library, you need to provide path for it as the linker has no idea where to look for it. The library is already included in STM32F4 Cube library, so you can do something like:

LDFLAGS += -LSTM32Cube_FW_F4_V1.19.0/Drivers/CMSIS/Lib/GCC -larm_cortexM4lf_math

Look into the directory to see what versions are available (there should be separate hard/soft float version). You can't simply use -lm here as the library file is actually called libarm_cortexM4lf_math.a and not libm.a.

Adding this at the very end of the Makefile (after all includes of cm-makefile) works for me in the stm32-cube example (which uses STM32F0 thus a different library name):

LDFLAGS += -L$(CUBE_DIR)/Drivers/CMSIS/Lib/GCC -larm_cortexM0l_math
adamheinrich commented 6 years ago

@johschmitz check this for C++ support: 9700fff5b23c873d81d7669c4cf68fc77f81681f

johschmitz commented 6 years ago

I got it working, thanks for your support.

Adam Heinrich notifications@github.com schrieb am Sa., 23. Juni 2018, 10:09:

@johschmitz https://github.com/johschmitz check 9700fff https://github.com/adamheinrich/cm-makefile/commit/9700fff5b23c873d81d7669c4cf68fc77f81681f

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/adamheinrich/cm-makefile/issues/1#issuecomment-399650518, or mute the thread https://github.com/notifications/unsubscribe-auth/AAvHizW87FrYNApqxkoWLtw-6n9d3eG7ks5t_ffPgaJpZM4U0MCn .