Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/140.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 如何在qt creator和msvc中使用boost正则表达式_C++_Qt_Visual C++_Boost_Boost Regex - Fatal编程技术网

C++ 如何在qt creator和msvc中使用boost正则表达式

C++ 如何在qt creator和msvc中使用boost正则表达式,c++,qt,visual-c++,boost,boost-regex,C++,Qt,Visual C++,Boost,Boost Regex,我的系统中已经安装了VS 2010。 因此,当我下载QT时(我必须使用QT,因为这是项目所需的),我使用并安装了它。 它能够自动检测Visual C++编译器,并且工作正常。 现在,我从boost.org下载了boost库,并使用visual studio命令提示符中的以下命令进行安装:- > bootstrap.bat msvc > > c:\boost_1_54_0>b2 install --prefix=c:/boostinst toolset=msvc-10.0

我的系统中已经安装了VS 2010。 因此,当我下载QT时(我必须使用QT,因为这是项目所需的),我使用并安装了它。 它能够自动检测Visual 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
之后,我打开QtCreator并添加了以下代码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;
    }
}
当我尝试构建时,它抛出以下错误

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();
}
遵循指示


然后在qt-project->run->arguments中添加参数

我曾尝试使用lambda运行代码,这会引发相同的错误。我想知道您是否真的需要使用
#include Not working dude。它抛出了一个编译错误。如果我给出
#include
,它就会接受。但是现在所有的头文件如regex.hpp等都抛出了错误。怎么办?
#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();
}
INCLUDEPATH+=C:\boost_1_54_0
LIBS+=-LC:\boost_1_54_0\stage\lib\