November 26, 2011

facat facat
Lab Rat
8 posts

exception mechanism of boost.regex conflicts with QT lib

 

a short piece of code:

  1. /////////////////////////////////////
  2. boost::regex reg;;
  3. try { reg.assign( "[]d"); }
  4. catch(std::runtime_error & e) { //exception }
  5. //////////////////////////

this code runs well in Eclipse with MingW. When I copy this code in my QT project and run, it seems that QT lib cannot handle the exception which boost.regex lib throws. A run time termination warning shows as a result. I’m using win7 64bit. My QT is integrated with MingW 4.4 .

Did any one encounter a similar problem? Could someone help me ?

[edit: please add @ code tags, Eddy]

5 replies

November 26, 2011

Gerolf Gerolf
Area 51 Engineer
3210 posts

AFAIK, Qt has exception handling turned off by default. But there should be switches in the pro file to switch it on again.

Look at the CONFIG variable description [doc.qt.nokia.com]

These CONFIG values control compilation flags: ….. These options are used to set the compiler flags: … exceptions —> Exception support is enabled. …
 Signature 

Nokia Certified Qt Specialist.
Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

November 26, 2011

facat facat
Lab Rat
8 posts

Gerolf wrote:
AFAIK, Qt has exception handling turned off by default. But there should be switches in the pro file to switch it on again. Look at the CONFIG variable description [doc.qt.nokia.com]
These CONFIG values control compilation flags: ….. These options are used to set the compiler flags: … exceptions —> Exception support is enabled. …

adding exception to CONFIG variant doesn’t work. Besides, there is message
“ Invalid parameter passed to C runtime function. “

November 26, 2011

Volker Volker
Robot Herder
5428 posts

  1.     -no-exceptions ..... Disable exceptions on compilers that support it.
  2.  *  -exceptions ........ Enable exceptions on compilers that support it.

The asterisk denotes the default.

Exception support should be enabled on all majore platforms by default. I know for sure it works on Windows (Visual Studio and MinGW) and the Mac, as I successfully catch exceptions thrown by GraphicsMagick.

November 26, 2011

facat facat
Lab Rat
8 posts

Finally I found the problem. It’s because boost.regex and my QT project was built under different version of gcc.

My regex was built under gcc 4.6. The default gcc which qt implements is gcc 4.4. So gcc 4.4 cannot handle the exception from libs built under gcc 4.6.

When I set the Path in Build Settings-> Build Environment, indicated qt compiler to find my gcc 4.6, everything is right.

Still I got a warning:
:-1: warning: cannot find entry symbol nable-stdcall-fixup; defaulting to 00401000

It seems qt still implements an old version ld.exe?

November 26, 2011

Volker Volker
Robot Herder
5428 posts

It does not cure the cause of your problems if you tweak the compiler settings in Creator. Your Qt is still built with gcc 4.4. So either rebuild Qt using gcc 4.6 or build your boost libs using gcc 4.4. Everything else is playing roulette, but not a stable solution.

In general, it’s almost never a good idea to mix object code built by different releases of a compiler (gcc 4.4 vs 4.6, Visual Studio 2008 vs. 2010, etc.)

 
  ‹‹ Timeline of releases      Need help in qt-creator!!! ››

You must log in to post a reply. Not a member yet? Register here!