C++ Program does not catch any exception

I'm developing a game, well a library to make games based on SFML and a game based on that library.

The problem is that when the program throws a exception the system crashes although there are try blocks with catch clauses that can catch it.

Even if I do either
1
2
3
4
5
6
	try{
		throw std::runtime_error("Error");
	}
	catch(std::exception &ex){
		
	}


or
1
2
3
4
5
	try{
		throw std::exception();
	}
	catch(...){
	}


the system crashes.

I don't understand why it happens. And what's more, it only occurs in my program, when I write the examples of above in a simple .cpp file and I compile it, the program catches the exceptions normally as it must be.

I'm using Code::Blocks and Netbeans to write the library and the program. I have the projects in both IDEs.
I use MinGW 4.8.1 compiler.

I hope someone have any idea of why it's happening and have a solution to the problem.

Thanks for read and answer.
Exceptions aren't necessarily the reason for program crashes- segmentation faults, for example, aren't able to be caught with try/catch. Are you sure it isn't something else?
Can you say what the "crash" is? console output and so on.

Since you have no code in your catch block, how can you tell it's not being caught before your crash?

Maybe something like cerr << ex.what() << endl; in your catch block...
if I put something like cerr << ex.what() << endl; in my catch block the program does not print anything.

The error message says "This application has requested the Runtime to terminate it in a usual way".
Does the application start up with no code running? Maybe you're using a DLL of a different version or from Visual Studio, or there may have been a calling convention mismatch. As a last resort you can try rebuilding SFML from source.

Does a simple project with the following code crash?
int main(){try{throw 0;}catch(...){}return 0;}
I solved the problem.

I had the idea that a compiler flag was causing the problem.

So I searched in the gcc.gnu.org the list of all compiler flags and reading I found that if my application wishes to throw and catch exceptions across different shared libraries I cannot use either -static-libgcc or -static-libstdc++ which I was using.

And when I remove this options from the linker flags the problem was solved.

Thanks for all replies.
Topic archived. No new replies allowed.