2013-07-18 26 views
0

我已經安裝了VS 2010,已經安裝在我的系統中。 所以當我下載QT(我必須使用QT作爲那個項目需求),我使用this link並安裝它。 它能夠自動檢測Visual C++編譯器,並且工作正常。如何使用qt創建器和msvc使用boost regex

現在我從boost.org下載Boost庫,並使用從Visual Studio命令提示符運行以下命令安裝: -

> bootstrap.bat msvc 
> 
> c:\boost_1_54_0>b2 install --prefix=c:/boostinst toolset=msvc-10.0 
> variant=debug ,release link=static threading=multi 

後,我打開Qt Creator的和下面的代碼添加CPP文件

#include <boost/regex.hpp> 
#include 
#include 

int main() 
{ 
    std::string line; 
    boost::regex pat("^Subject: (Re: |Aw:)*(.*)"); 

    while (std::cin) 
    { 
     std::getline(std::cin, line); 
     boost::smatch matches; 
     if (boost::regex_match(line, matches, pat)) 
      std::cout << matches[2] << std::endl; 
    } 
} 

並添加使用ADD庫的庫,並生成以下.pro文件。

TEMPLATE = app 
CONFIG += console 
CONFIG -= app_bundle 
CONFIG -= qt 
INCLUDEPATH += C:\boostinst\include\boost-1_54 #if i remove this line, then also the same error 



win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../boostinst/lib/ -llibboost_regex-vc100-mt-1_54 
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../boostinst/lib/ -llibboost_regex-vc100-mt-1_54d 
else:unix: LIBS += -L$$PWD/../../../boostinst/lib/ -llibboost_regex-vc100-mt-1_54 

INCLUDEPATH += $$PWD/../../../boostinst/include 
DEPENDPATH += $$PWD/../../../boostinst/include 

當我嘗試打造,它引發以下錯誤

C:\用戶\ XXX \ newcp \ main.cpp中:24:錯誤:C1083:無法打開包含文件:「升壓/ regex.hpp':沒有這樣的文件或目錄

我是錯過了什麼或做錯了什麼?請任何人儘快回覆。

+0

我已經嘗試運行使用lambda,這是拋出相同的錯誤代碼。 – Sayok88

+0

我想知道你是否真的需要使用''#include

+0

不工作的傢伙。它拋出一個編譯錯誤。 – Sayok88

回答

1

解決:使用下面的命令在32位號樓boost_154_00操作系統Win7和MSVC-10.0

>  cd C:\boost_1_54_0\tools\build\v2\engine 
>  build.bat msvc 
> 
>  cd boost_1_54_0 
>  
>  set PATH=%PATH%;C:\boost_1_54_0\tools\build\v2\engine\bin.ntx86 
>  
>  bjam toolset=msvc-10.0 

然後在QT創建一個新的項目,並在main.cpp中粘貼

#include <QCoreApplication> 
#include <boost/regex.hpp> 
#include <iostream> 
#include <string> 

int main(int argc, char *argv[]) 
{ 
    QCoreApplication a(argc, argv); 
    std::string line; 
    boost::regex pat("^Subject: (Re: |Aw:)*(.*)"); 

    while (std::cin) 
    { 
     std::getline(std::cin, line); 
     boost::smatch matches; 
     if (boost::regex_match(line, matches, pat)) 
      std::cout << matches[2] << std::endl; 
    } 
    return a.exec(); 
} 

的.pro添加

INCLUDEPATH+=C:\boost_1_54_0 
LIBS+=-LC:\boost_1_54_0\stage\lib\ 

關注方向here

,然後添加在QT項目 - 參數>運行 - >參數