[英]How to use boost regex with qt creator and msvc
我的系統中已經安裝了VS 2010。 因此,當我下載QT時(我必須使用QT來表示項目要求所在的位置),我使用了此鏈接並安裝了它。 它能夠自動檢測可視的C ++編譯器,並且運行良好。
現在,我從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 Library添加了該庫,並生成了以下.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:\\ Users \\ xxx \\ newcp \\ main.cpp:24:錯誤:C1083:無法打開包含文件:'boost / regex.hpp':沒有這樣的文件或目錄
我是否缺少某些東西或做錯了什么? 請任何人盡快答復。
求助:使用以下命令在32位操作系統Win7和msvc-10.0中構建boost_154_00
> 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\
按照這里的指示
然后在qt project-> run-> arguments中添加參數
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.