Search code examples
c++exceptionbuildqmakemingw32

How to enable exception handling in mingw


I am new to Mingw and C++ programming. I am trying to build a C++ project but getting following error.

error: exception handling disabled, use -fexceptions to enable.

Where I need to pass this -fexceptions parameter. When I am trying

mingw32-make -fexceptions

I am getting follwoing error.

mingw32-make: exceptions: No such file or directory


Solution

  • Since you're using Qt, add "exceptions" to the CONFIG variable in your project file (the *.pro file):

    CONFIG += exceptions
    

    This should take care of passing the correct compiler flags.

    In any event, do not modify the generated Makefile. With Qt's qmake, the Makefile is just an auto-generated file.