[En-Nut-Discussion] Compiler/linker problems using arm-none-eabi-gcc for C and C++ code
giorgiospike at yahoo.no
Sun Sep 22 14:35:43 CEST 2013
I am using Ethernut 5, and I have an application which is mainly C code, but I want to also use some functions in some C++ files. I have therefore written a wrapper (using extern "C" where appropriate), and tested with the simple "cppdemo" that is included in my Ethernut 4.10 installation. I am able to compile and link both C and C++ files when I use the "cppdemo" file in my code, but when I replace the "cppdemo" file with the C++ files I want to use, it results in many linker errors, mainly "undefined reference" errors to some C++ functions, and undefined reference to '__dso_handle' and '__dynamic_cast'. In addition, "hidden symbol `__dso_handle' isn't defined". Currently, all C files are compiled using "arm-none-eabi-gcc" and the C++ files are compiled with "arm-none-eabi-g++". At the link stage "arm-none-eabi-gcc" is used.
After some search on the web, and attempts at different suggestions, I have tried editing "CC = $(TRGT)gcc" to "CC= $(TRGT)g++" in Makevars.gcc, and in this way all files (both C and C++) are compiled and linked using "arm-none-eabi-g++". However, this approach rather results in "undefined reference" errors to some C functions.
I will now like to keep the compile stage as before (i.e. compile C with $(TRGT)gcc and C++ with $(TRGT)g++), and try linking with "arm-none-eabi-g++" instead of "arm-none-eabi-gcc". I will therefore like to know which file I can edit in order to specify "arm-none-eabi-g++" at only the link stage. Any other suggestion to help solve my problem is also very welcome.
More information about the En-Nut-Discussion