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.
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?
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 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.