Undefined link to __cxa_end_cleanup '

I am trying to create a project in C ++, but as it completes this error causes:

undefined reference to __cxa_end_cleanup' 

The toolchain used is ARM GCC 4.7.3, and the custom linker flags are:

 -mthumb -march=armv6-m -T .\Generated_Source\PSoC4\cm0gcc.ld -g -Wl,-Map,${OutputDir}\${ProjectShortName}.map -specs=nano.specs -Wl,--gc-sections 

What is the common cause of the error above? And which link flags would resolve this error?

+6
source share
2 answers

Whenever you get undefined errors, you are not binding what suits your build settings. You have three options:

  • Change the build options.
  • Provide a library.
  • Provide an alternative library.
  • Avoid calling functions / using data [not possible here].

In this case, Ian Lance Taylor gives the answer that -lsupc++ needed. In addition, if you are using gcc , you should switch to g++ , which will add the appropriate libraries for your C ++ binaries. See the manual for more information.

If you are deeply rooted, you can try creating your own library using a function. Source source __cxa_end_cleanup() is available in this case for reference. It looks like the function is to restore the registers during the exception or exit() conditions. If you do not use this function, you can block the function (at your own peril and risk); but the code is quite small and even on Cortex-M, I would contact the provided library.

+7
source

Add -lC ++ to the list of linker libraries

+1
source

Source: https://habr.com/ru/post/972935/


All Articles