1

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

Nikos C.
  • 50,738
  • 9
  • 71
  • 96
Vinod
  • 1,076
  • 2
  • 16
  • 33
  • 2
    Shouldn't you be adding `-fexceptions` to the `CXXFLAGS` in your makefile instead of passing it as a command line argument? – Praetorian Nov 15 '12 at 16:24
  • Actually, its a QT project and make file has been generated using qmake. So, I need to modify the generated make file? – Vinod Nov 15 '12 at 16:27

2 Answers2

4

If you're using straight g++ from the command line, you should do:

g++ -fexceptions ...rest of command...

If you're using Makefiles, add it to CXXFLAGS (and then just build with make as usual):

# in your Makefile
CXXFLAGS := -fexceptions
...rest of your makefile...

The reason you get the "No such file or directory" error is because -f is an option for make which specifies the file to use, so when you pass -fexceptions to make it says "-f means he wants to use the following file "exceptions"... let me try and find a file named "exceptions"" and then, of course, it errors out when it can't find a file by that name.

The CXXFLAGS variable in your Makefile get passed to your compiler as flags/options, and is where you should stick any extra compiler flags (like -fexceptions).

Edit: If you're using qmake, try adding CONFIG += exceptions to your project file.

Cornstalks
  • 37,137
  • 18
  • 79
  • 144
3

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.

Nikos C.
  • 50,738
  • 9
  • 71
  • 96