VS2008 编译 boost 1.45 环境
参考文章: 如何在visual studio 2010中使用Boost: http://stackoverflow.com/questions/2629421/how-to-use-boost-in-visual-studio-2010 1、下载zip文件 解压到 d:/boost_1_45_0 2、运行bootstrap.bat 编译出 bjam.exe 3、改D:/boost_1_45_0/tools/build/v2/user-config.jam 找到如下所示的字符串。 # MSVC configuration # Configure msvc (default version, searched in standard location # and PATH). # using msvc ; 在此字符串下面添加如下命令行,并保存。 using msvc : 9.0 : : /wd4819 /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 ;
4、打开 命令提示符 CD到d:/boost_1_45_0目录。输入如下命令开始编译 bjam --without-python --toolset=msvc-9.0 --prefix=d:/develop/boost install 参数说明 --without-python 表示不使用 python --toolset : 所使用编译器,Visual Studio 2008为msvc-9.0 --prefix:编译后library的安装目录 这一步要花很长时间 5、设置开发环境 打开VS2008 选择 工具->选项->vc++目录 设置包含文件目录D:/develop/boost/include/boost-1_45 设置引用文件目录:d:/develop/boost/lib 完成.可以使用了. 6、测试代码 #include <boost/regex.hpp> #include <string>
using namespace boost ; using namespace std ;
int main(int argc, const char** argv) { regex reg("//d{3}([a-zA-Z]*)"); string str="123"; assert(regex_match(str,reg)); return 0; }
附录1:可能的错误 fatal error C1083: Cannot open include file: boost/regex.hpp: No such file or directory 类似的错误可能是设置开发环境vc目录设置错误,注意,只需要包含 */include/boost-1_45而不要包含boost这一层次*/include/boost-1_45/boost
附录2:bjam 命令说明
Boost.Build V2 (Milestone 12) Boost.Jam 03.1.16 Project-specific help: Project has jamfile at Jamroot Usage: bjam [options] [properties] [install|stage] Builds and installs Boost. Targets and Related Options: install Install headers and compiled library files to the ======= configured locations (below). –prefix=<PREFIX> Install architecture independent files here. Default; C:/Boost on Win32 Default; /usr/local on Unix. Linux, etc. –exec-prefix=<EPREFIX> Install architecture dependent files here. Default; <PREFIX> –libdir=<DIR> Install library files here. Default; <EPREFIX>/lib –includedir=<HDRDIR> Install header files here. Default; <PREFIX>/include stage Build and install only compiled library files ===== to the stage directory. –stagedir=<STAGEDIR> Install library files here Default; ./stage Other Options: –build-type=<type> Build the specified pre-defined set of variations of the libraries. Note, that which variants get built depends on what each library supports. minimal (default) – Builds the single "release" version of the libraries. This release corresponds to specifying: "release <threading>multi <link>shared <link>static <runtime-link>shared" as the Boost.Build variant to build. complete – Attempts to build all possible variations. –build-dir=DIR Build in this location instead of building within the distribution tree. Recommended! –show-libraries Displays the list of Boost libraries that require build and installation steps, then exit. –layout=<layout> Determines whether to choose library names and header locations such that multiple versions of Boost or multiple compilers can be used on the same system. versioned (default) – Names of boost binaries include the Boost version number and the name and version of the compiler. Boost headers are installed in a subdirectory of <HDRDIR> whose name contains the Boost version number. system – Binaries names do not include the Boost version number or the name and version number of the compiler. Boost headers are installed directly into <HDRDIR>. This option is intended for system integrators who are building distribution packages. –buildid=ID Adds the specified ID to the name of built libraries. The default is to not add anything. –help This message. –with-<library> Build and install the specified <library> If this option is used, only libraries specified using this option will be built. –without-<library> Do not build, stage, or install the specified <library>. By default, all libraries are built. Properties: toolset=toolset Indicates the toolset to build with. variant=debug|release Select the build variant link=static|shared Whether to build static or shared libraries threading=single|multi Whether to build single or multithreaded binaries runtime-link=static|shared Whether to link to static or shared C and C++ runtime. Configuration help: Configuration file at F:/Develop/boost_1_37_0 C++/boost_1_37_0/tools/build/v2 user-config.jam This file is used to configure your Boost.Build installation. You can modify this file in place, or you can place it in a permanent location so that it does not get overwritten should you get a new version of Boost.Build. See: http://boost.org/boost-build2/doc/html/bbv2/reference.html#bbv2.reference.init for documentation about possible permanent locations. General command line usage: bjam [options] [properties] [targets] Options, properties and targets can be specified in any order.
Important Options: * –clean Remove targets instead of building * -a Rebuild everything * -n Don’t execute the commands, only print them * -d+2 Show commands as they are executed * -d0 Supress all informational messages * -q Stop at first error * –debug-configuration Diagnose configuration * –debug-building Report which targets are built with what properties * –debug-generator Diagnose generator search/execution Further Help: The following options can be used to obtain additional documentation. * –help-options Print more obscure command line options. * –help-internal Boost.Build implementation details. * –help-doc-options Implementation details doc formatting. |