如何构建Boost :: program_options

时间:2010-06-25 12:25:56

标签: c++ boost build libraries

我想使用boost :: program_options。在我安装了boost之后,我认为我必须构建单独的program_options(http://www.boost.org/doc/libs/1_43_0/more/getting_started/windows.html)。但我不知道该怎么做。

我正在尝试编译C:\ Program Files \ boost \ boost_1_42 \ libs \ program_options \ example \ first.cpp(http://www.boost.org/doc/libs/1_42_0/doc/html/program_options/tutorial.html)但可能由于我没有构建库我有这个错误:

LINK : fatal error LNK1104: cannot open file 'libboost_program_options-vc90-mt-gd-1_42.lib' 

编辑:我使用了BoostPro Computing提供的安装程序,因此我跳过了二进制文件的安装(http://www.boost.org/doc/libs/1_43_0/more/getting_started/windows.html#install-visual-studio-binaries

编辑:我也按照http://www.boost.org/doc/libs/1_43_0/more/getting_started/windows.html#build-from-the-visual-studio-ide

上的说明操作

4 个答案:

答案 0 :(得分:2)

阅读Boost 1.54 Getting Started on Windows guide后,您应该采取以下步骤(program_options is a header only library)。您需要安装MSVC编译器。

  1. Download Boost's source code from here并安装它。

  2. 从命令行(最好是VS的开发人员命令提示符):

    bootstrap.bat

    bjam.exe --build-type=complete msvc stage --with-program_options

  3. 这将在几分钟内结束,就是这样!这些库位于目录.\bin.v2\libs\program_options\build中。

    顺便说一句,你可以看到你可以使用bjam --show-libraries构建哪些库。

答案 1 :(得分:1)

我跟着these steps并且效果很好。那就是构建必须单独构建的少数boost库。

我建议你阅读整篇文件。

答案 2 :(得分:0)

您可能希望使用预编译的二进制文件,可以将其下载here

确保在VC项目中设置库路径以指向增强库。

答案 3 :(得分:0)

使用CLion和CMake,我在CMakeLists.txt中添加了以下内容:

target_link_libraries(myapp boost_program_options)