2013-07-18 3 views
0

내 시스템에 VS 2010이 이미 설치되어 있습니다. 그래서 내가 QT를 다운로드했을 때 (나는 프로젝트 요구가 무엇인지 QT를 사용해야한다), 나는 this link을 사용하고 그것을 설치했다. Visual C++ 컴파일러를 자동으로 감지하여 정상적으로 작동하고있었습니다.qt creator와 msvc를 사용하여 boost regex를 사용하는 방법

는 지금은 boost.org에서 부스트 라이브러리를 다운로드 및 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는 창조주 열어 그 후 다음과 같은 코드 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 ': 해당 파일이나 디렉토리가 없습니다.

Am i 뭔가 누락되었거나 잘못 되었습니까? 누구나 가능한 한 빨리 응답하십시오.

+0

저도 같은 오류를 던지고있다 람다를 사용하여 코드를 실행 노력했다. – Sayok88

+0

regex.hpp가''C : \ boostinst \ include \ boost \ regex.hpp''에 있다고 결론을 내릴 때는''#include

+0

이 작동하지 않습니다. 컴파일 오류가 발생합니다. – Sayok88

답변

1

해결 : 32 비트에서 boost_154_00 구축 OS Win7에와 MSVC 10.0 QT에서 다음

>  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 

새로운 프로젝트를 생성하기위한 다음 명령을 사용하여 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 프로젝트 -에 인수를 추가> 실행 -> 인수