Need explanation please ( Mingw and VS2010 and third party library)



  • Hello

    I have problem using Boost library in Qt and i guess its because i compiled boost library using VS compiler.

    Here is situation :

    I use Qt 5 with VS2010 compiler (NOT Mingw)
    I need to use boost library in my Qt project
    So, i downloaded Boost and compiled using VS2010 compiler
    I failed to make it working as Qt can not find boost/regex.hpp

    Here is my question :

    Despite of setting VS2010 compiler in QT Creator , is it still necessary to compile Boost library with Mingw to use it in my project !?

    I really appreciate if someone can help me.

    All the best



  • You need boost built with the same compiler, but the not found header is not a compiler binary compatibility issue.

    Did you added the path to boost include into the .pro file? See "include path":http://qt-project.org/doc/qt-4.8/qmake-variable-reference.html#includepath and add the path to boost include, also "libs":http://qt-project.org/doc/qt-4.8/qmake-variable-reference.html#libs (if you use libraries from boost that are not header-only)

    And Qt already has "regexp":http://qt-project.org/doc/qt-4.8/qregexp.html so maybe you can escape without boost dependency this time.



  • Hi

    Thanks a lot :)

    Actually i included paths , i tried these :

    INCLUDEPATH +=H:/boost_1_53_0
    LIBS +=-L "H:/boost_1_53_0/stage/lib"

    AND

    INCLUDEPATH +=H:/boost_1_53_0
    LIBS +=-L "H:/boost_1_53_0/stage/lib" -libboost_regex-vc100-mt-1_53

    And a few other combinations

    I am familiar with Qregex as well but unfortunately its not as good as i need

    My biggest problem is that it doesn't support Non-greedy quantifiers.
    For example \b.*?(\r"$) doesn't work (because of "?" character) and setting Minimal to True doesnt solve my problem

    Also there are other issues :
    "http://qt-project.org/wiki/Regexp_engine_in_Qt5":http://qt-project.org/wiki/Regexp_engine_in_Qt5

    I wish i could use QtRegx , its disappointing

    However, any help on solving my issue ?

    i tried :
    #include "boost/regex.h"
    #include "boost/regex.hpp"
    #include <boost/regex.hpp>
    I got this error :
    error: C1083: Cannot open include file: 'boost/regex.h': No such file or directory

    Thanks


  • Moderators

    welcome to devnet

    I am also working boost's regex since QRegExp does not allow certain things, which are available in boost.

    @
    INCLUDEPATH += .
    "c:/Boost/boost_1_52_0"
    @
    is what I am using to add to the include path.
    I am using
    @
    #include <boost/regex.hpp>
    @
    in the code. This does work.
    Your error message is still with the compiler. It does not take into account any compiler specific things yet.
    You cannot mix MinGW and MSVC compiled binaries. Also between versions and memory models of the different compilers you have to be careful. However, once again, your problem comes up before this.

    You need to check if the includes are really there where you are expecting them.
    In addition, it would be good to rerun qmake "right mouse click on the project name (Run qmake)" in qt creator.



  • Hello

    Thank you for your help. i appreciate that :)

    Infact i solved that problem last night. I used "Clear All" and then ran "qMake" and the error is gone.

    However it does not work yet :(
    I got this error :

    error: Macro argument mismatch.

    on this line : BOOST_MPL_AUX_NA_SPEC(3, if_)

    in if.hpp file

    I find a few workarounds but i still have problem. can you take a look at this thread too :
    "http://qt-project.org/forums/viewthread/25749/":http://qt-project.org/forums/viewthread/25749/

    How did you solve it? (You should have had same problem if you are using boost 4.8 and later)

    Best regards


  • Moderators

    I have checked all files in my source directory and could not find anywhere the macro BOOST_TT_HAS_OPERATOR_HPP_INCLUDED
    The directory includes more than 18 GB including all those obj and libs, but the Qt stuff itself. So I am pretty sure that this has not been an issue for me.

    I am using boost 1.52.0 as you see from my previously posted INCLUDEPATH. I think I started to combine with boost regex with Qt 4.8 only. Probably Qt 4.8.2 up to Qt 4.8.4 using msvc 2005 (also as IDE) and recently with Qt creator 2.6 (.0 up to .2) and MinGW 4.6.2 (32 bit only), MinGW 4.7.2 (32 bit only) and MinGW 4.7.2 dual build (32 & 64 bit). The most annoying part was the recompilation of boost libs with all those different compilers. However, that is not blame on boost, but on the current MinGW situation :(

    I had some problems also with moc. However, I do not remember that there was anything specific for boost and/or regex there.



  • Hey
    Thanks for your answer

    I try to use boost 1.53.0 and error is in boost_1_53_0\boost\mpl\if.hpp file

    If i cant figure it out , then i probably will use boost 1.47 OR use "PCRE ":http://www.pcre.org/ as a alternative regex library which i don't expect to be easy to compile.

    I guess you didn't have this problem because you are using previous version of Qt. mine is Qt 5.0

    By the way, thank you for your consideration :)



  • It's probably a bit late to give an answer to this thread, but I can probably add some.

    I have used boost versions from 1.51 through 1.54 in the past together with Qt 4.8 through 5.1 on Windows 7.

    I use boost from within a top-level boost folder with subfolders for each version (e.g. C:\Program Files\Boost\boost_1_53_0 etc.) The libraries and includes are in /stage/lib and /boost respectively. I have an environment variable named boost to point to the desired boost version. Finally, to use boost from within Qt, I add the following two lines to the project file:
    @
    INCLUDEPATH += $$(boost)
    LIBS += -L"$$(boost)/stage/lib/"
    @

    This works for both, g++ and MSVC. However, for g++ I need to add any libraries with an additional:
    @
    win32-g++ {
    BOOST_TARGET = mgw48-mt-s-1_54
    LIBS += -lboost_filesystem-$${BOOST_TARGET}
    -lboost_chrono-$${BOOST_TARGET}
    -lboost_system-$${BOOST_TARGET}
    }
    @

    I have run into similar problems with (boost::) filesystem, exception and posix_time. (I haven't used regex that much). I could address the issue by excluding the boost headers from MOC:
    @
    #ifndef Q_MOC_RUN
    #include <boost/exception/all.hpp>
    #include <boost/filesystem.hpp>
    #endif
    @

    It is not the most ideal solution but it is absoultely portable.
    This solution is also mentioned "here:":https://bugreports.qt-project.org/browse/QTBUG-22829?focusedCommentId=176766&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-176766

    I have to add that the problem was most apparent in Qt 4.8. With Qt 5.0 I was able to remove a number of boost headers from the "MOC_RUN cage". I have not revisited all my code with Qt 5.1, so there might be even less.

    Willi


Log in to reply
 

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