Вопрос

I had VS 2010 installed already installed in my system. So when i downloaded QT (I have to use QT as thats what the project req was in) ,i used this link and installed it. It was able to auto detect the visual C++ compilers and was working fine.

Now I downloaded boost library from boost.org and installed using the following commands from visual studio command prompt:-

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

after that i opened qt creator and added the following code cpp file

#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;
    }
}

and added the library using ADD Library and the following .pro file was generated.

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

When i try to build , it throws the following error

C:\Users\xxx\newcp\main.cpp:24: error: C1083: Cannot open include file: 'boost/regex.hpp': No such file or directory

Am i Missing something or doing something wrong? Please anyone respond as soon as possible.

Это было полезно?

Решение

SOLVED: Use the following commands for Building boost_154_00 in 32-bit OS Win7 and 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

Then in QT create a new project and paste in 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();
}

in .pro add

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

Follow directions here

and then add arguments in qt project->run->arguments

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top