用java的时候觉得挺折腾,回头来弄c++才知道什么叫折腾。。。汗。。。
首先参考我写的这篇文章:http://www.cnblogs.com/qrlozte/p/4100892.html
我从sourceforge把整个boost的zip下载下来以后,我主要是在编译 boost regex的时候出问题了:boost有很多library,regex只是其中一个,怎么编译regex?
当然,第一步是查看文档,找到boost-path/doc/html/index.html打开,翻了半天倒找regex的说明文档(其实可以直接从boost-path/libs/regex/index.html直接找到)
文档里面说:
Building from Source
The Regex library is "just a bunch of source files": nothing special is required to build them.
You can either build the files under boost-path/libs/regex/src/*.cpp as a library, or add them directly to your project. This is particularly useful if you need to use specific compiler options not supported by the default Boost build.
于是找到这个目录,确实发现了不少的cpp文件,直接打开terminal
g++ -c *.cpp
于是报了一大堆找不到头文件的error,一看,是类似于<boost/regex/xxx.hpp>之类的找不到,回过头去看文档,于是,在“Getting Started on Windows”这个页面找到了说明,发现boost-path/boost中全是头文件,该页面说明如下:
This is a sketch of the resulting directory structure:
boost_1_57_0\ .................The “boost root directory” index.htm .........A copy of www.boost.org starts here boost\ .........................All Boost Header files lib\ .....................precompiled library binaries libs\ ............Tests, .cpps, docs, etc., by library index.html ........Library documentation starts here algorithm\ any\ array\ …more libraries… status\ .........................Boost-wide test suite tools\ ...........Utilities, e.g. Boost.Build, quickbook, bcp more\ ..........................Policy documents, etc. doc\ ...............A subset of all Boost library docs
然后就把boost-path/boost这个文件夹拷贝到MinGW/include目录下,也就是说,得到:MinGW/include/boost,从而成为了编译器默认搜索路径的一部分
再次打开terminal:
g++ -c *.cpp // 编译成.o文件 ar -r boost_regex.a *.o // 打包成.a文件(库文件,类似java的jar包,但是要配合该库的头文件才能使用)
好,参照这篇文章的步骤:http://www.cnblogs.com/qrlozte/p/4100892.html
大功告成