How to get Boost libraries binaries that work with Visual Studio?
Here's a question you may have seen around the 'nets in various forms...summed up here for you googling pleasure :-)
I have a project that is built with Microsoft's Visual Studio and uses functionality from boost (http://www.boost.org/). I already have my project working with some of the libraries that are header only (no binary library needed to link with). How or where can I get the windows binaries f开发者_开发问答or the other libraries?
There are three different options for accessing the binary libraries:
1) Build them from source.
Go into the boost directory and run:
bootstrap
.\bjam
Or get more complicate and do something like:
bjam --stagedir="c:\Program Files\Boost" --build-type=complete --toolset=msvc-9.0 --with-regex --with-date_time --with-thread --with-signals --with-system --with-filesystem --with-program_options stage
2) Use the BoostPro installer (http://www.boostpro.com/download) to get the specific libraries that you need.
This is very nice because it only downloads and installs the files that you say you want. However, it never has the most current version available, and there are no 64 bit binaries.
3) Download the entire set of libraries (http://boost.teeks99.com)
Easy to use, simple to do, but the libraries are huge (7GB unzipped!).
Edit 2013-05-13: My builds are now available (starting from 1.53) directly from the sourceforge page.
conda-forge (automated cross-platform cloud build tool and package manager) provides binaries for all major platforms:
https://anaconda.org/conda-forge/boost
You can now get Boost binaries from:
http://sourceforge.net/projects/boost/files/boost-binaries/
However they do not specify whether it is release or debug version.
I used to prefer using BoostPro to install the Boost libraries that needed separate compilation, such as Boost.Regex, but alas this no longer seems to be supported.
Go to the Boost Getting Started for Windows page, it tells you pretty much everything you need to know in section 5.2.1. Here is a simple guide (with screenshots) that shows you how to get started.
To summarize, from the command prompt you need to run the following commands:
> boostrap.bat
> .\b2
Running the .\b2 command can take quite some time.
And then in your Visual Studio project properties, you'll need to:
- Select the C/C++ > General tab and set the Additional Include Directories field
- Select the Linker > General tab and set the Additional Library Directories field.
For step 2, this is typically the stage\lib directory of your Boost root directory.
Build them yourself. Download a bjam executable from the boost website, then execute the following command from the boost src root directory:
bjam --toolset=msvc --build-type=complete define=_BIND_TO_CURRENT_MFC_VERSION=1 define=_BIND_TO_CURRENT_CRT_VERSION=1 stage
Then go get some coffee or leave it running over night. After that you get results in the 'stage' folder. Add this directory to your 'library files' in options->projects and solutions->VC++ directories.
Consider some of the recently sprung-up package managers for C++
- vcpkg, https://github.com/microsoft/vcpkg/tree/master/ports/boost
- conan, https://conan.io/center/boost
- also anaconda conda-forge, https://anaconda.org/conda-forge/boost
Originally, I wanted to use Bazel, but it does not have boost yet in its bzlmod registry.
vcpkg instructions
- Follow the Get started with vcpkg document to install and setup vcpkg
- Install boost for x64-windows by running
vcpkg install --triplet=x64-windows boost-program-options boost-system boost-test
See also the docs in the vcpkg project repo (link goes to rendered readthedocs version).
1) navigate to boost directory
2) run bootstrap - note: bjam doesn't appear to work at this point, but maybe i did something wrong
3) run .\b2 this should set up boost defaulting to what it detects as your primary, or maybe most recent windows toolset, so for me this is msvc11.0
then you wait a while, and voila!
as the above says, just include the directories of the boost libs (D:\boost_1_5x_x\stage\lib) and includes that you use in the respective Additional Directories fields. You do not need to necessarily do this from "C/C++" or "Linker". there is a heading VC++ that has all of the relevant fields there. you can also, if you are regularly using boost, include them in the inherited directories listing
**edit: only just realized that the post above outlines this. very sorry.
精彩评论