c++ - How to use boost regex with qt creator and msvc -


i had vs 2010 installed installed in system. when downloaded qt (i have use qt thats project req in) ,i used this link , installed it. able auto detect visual c++ compilers , working fine.

now downloaded boost library boost.org , installed using following commands 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 opened qt creator , added 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 library using add library , following .pro file generated.

template = app config += console config -= app_bundle config -= qt includepath += c:\boostinst\include\boost-1_54 #if remove line, 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 try build , throws following error

c:\users\xxx\newcp\main.cpp:24: error: c1083: cannot open include file: 'boost/regex.hpp': no such file or directory

am missing or doing wrong? please respond possible.

solved: use following commands building boost_154_00 in 32-bit os 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 

then in qt create new project , 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 add arguments in qt project->run->arguments


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -