Exception mechanism of boost.regex conflicts with QT lib



  • a short piece of code:
    @
    /////////////////////////////////////
    boost::regex reg;;
    try { reg.assign( "[]d"); }
    catch(std::runtime_error & e) { //exception }
    //////////////////////////
    @
    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]



  • 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":http://doc.qt.nokia.com/4.7/qmake-variable-reference.html#config

    [quote]
    These CONFIG values control compilation flags:
    .....
    These options are used to set the compiler flags:
    ...
    exceptions --> Exception support is enabled.
    ...
    [/quote]



  • [quote author="Gerolf" date="1322296085"]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":http://doc.qt.nokia.com/4.7/qmake-variable-reference.html#config [quote] These CONFIG values control compilation flags: ..... These options are used to set the compiler flags: ... exceptions --> Exception support is enabled. ... [/quote][/quote]
    adding exception to CONFIG variant doesn't work. Besides, there is message
    " Invalid parameter passed to C runtime function. "



  • @
    -no-exceptions ..... Disable exceptions on compilers that support it.

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



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



  • 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.)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.