Esp32-snippets: C++ exception handling build/compile errors.

Created on 26 Nov 2017  路  8Comments  路  Source: nkolban/esp32-snippets

Hello, I build from the bash and have cpp_utils in my components folder as instructed, when going make flash monitor it starts building but when it gets to HttpServer it throws as follows:

CXX build/cpp_utils/HttpServer.o
MyPath/components/cpp_utils/./HttpServer.cpp: In member function 'virtual void HttpServerTask::run(void*)':
MyPath/components/cpp_utils/./HttpServer.cpp:195:26 error: exception handling disabled, use -fexceptions to enable
    catch(std::exception &e) {
                          ^
make[1]: *** [HttpServer.o] Error 1
make: *** [component-cpp_utils-build] Error 2

Any suggestions?

Kind regards,

Anthony

question waiting

All 8 comments

Please check if you have enabled exception handling in menuconfig:
make menuconfig

menuconfig->compiler options-> C++ exceptions

Issue #232 was just created and code changed against it. Now when we try and compile code that expects C++ exception handling to be present and it isn't switched on, the compilation checks for it to be on and, if note, logs a more instructive message telling the user to switch on with some hints on how to do that.

Hello Neil, but how can we do the "make menuconfig". If I try in esp32-snippets/cpp_utils the system answer
"There is no rule to the objective 'menuconfig'"

Kind regards

You need to to use make menuconfig in your project folder, not in cpp_utils.

thanks, but I am Arduino user and compile with makefile.arduino in cpp_utils and the failure is on the Arduino side but referred to BLE library. I try to do the menuconfig on other projects but didn't work.

Best regards

@jestebanes Have a read through this issue - #228

In the latest BLE C++ classes we started to exploit C++ exception handling. In the latest ESP-IDF, Espressif have given us the ability to throw an exception. This is great. It means that code can throw an exception if it fails rather than return a failing return code which must always be checked. If your read #228 you will find that although exception handling is now part of ESP-IDF, it is not turned on by default. The Arduino-ESP32 apparently ships a pre-compiled version of the ESP-IDF as part of its distribution. If one is using Arduino IDE, then one uses that ESP-IDF ... which has not yet had exception handling switched on. Mr @me-no-dev believes he will be able to turn that on in a future release of the Arduino-ESP32 libraries. In the interim, your choices are:

  1. Use the BLE C++ classes that come with the Arduino-ESP32 package which don't have exception handling in them.
  2. Use the latest BLE C++ classes with the Arduino-ESP32 package but don't use the Arduino IDE but instead use the Arduino-ESP32 package as an ESP-IDF component. This will allow you to change the configuration options of how the ESP-IDF is compiled including the ability to switch on C++ exception handling.

So apparently it doesn't make it a default when compiling? We are using make defconfig in our CI script on a remote linux machine and are now getting a build error because of that. How can this be enabled without using the menuconfig UI?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mahdikan picture mahdikan  路  4Comments

jim-ber picture jim-ber  路  8Comments

d3cline picture d3cline  路  4Comments

Lakoja picture Lakoja  路  8Comments

Tavo7995 picture Tavo7995  路  7Comments