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.