How to build Boost::program_options

随声附和 提交于 2021-02-07 13:29:15

问题


I wanted to use boost::program_options. After I installed boost, I think that I have to build separatly program_options (http://www.boost.org/doc/libs/1_43_0/more/getting_started/windows.html). But I don't know how to do it.

I am trying to compile the 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) but probably due to I didn't build the library I have this error:

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

EDIT: I used the installers supplied by BoostPro Computing so I skipped the installation of the binaries (http://www.boost.org/doc/libs/1_43_0/more/getting_started/windows.html#install-visual-studio-binaries)

EDIT: I also followed the instructions at http://www.boost.org/doc/libs/1_43_0/more/getting_started/windows.html#build-from-the-visual-studio-ide


回答1:


After reading the Boost 1.54 Getting Started on Windows guide these are the steps that you should take (program_options is a header only library). You need to have a MSVC compiler installed.

  1. Download Boost's source code from here and install it.

  2. From a command line (preferably the Developer Command Prompt for VS):

    bootstrap.bat

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

This will finish in a couple of minutes and that's it! The libraries are located in the directory .\bin.v2\libs\program_options\build.

BTW you could see which libraries you can build using bjam --show-libraries.




回答2:


I've followed these steps and it worked pretty well. That is to build the few boost libraries that must be built separately.

I suggest you read the entire document.




回答3:


You might want to use precompiled binaries, which can be downloaded here.

And make sure to set the library path in your VC project to point to boost libraries.




回答4:


Using CLion and CMake, I added the following to CMakeLists.txt:

target_link_libraries(myapp boost_program_options)



来源:https://stackoverflow.com/questions/3117945/how-to-build-boostprogram-options

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!