Download & Unzip
Download source code from http://www.boost.org/and unzip
Open a native tool command prompt for VS
- CD Boost_sourcecode_dir
- Bootstrap
If you need to compile Boost.python you need to add the following in Boost_sourcecode_dir\tools\build\example\user-config.jam:
14.0;2.7 : F:\\ProgramData\\Anaconda2 : F:\\ProgramData\\Anaconda2\\include : F:\\ProgramData\\Anaconda2\\libs
Use the b2 command to compile, the specific command line parameters can be viewed in the Boost_sourcecode_dir\jamroot file, if you want to compile x64, remember to add address-model=64, otherwise the default compile both 32-bit and 64-bit
Introduction of dynamic library/static library in VS Project
- If you want to use Boost.python, remember to introduce Python's include and Libs
- Using the dynamic link library requires #define Boost_all_dyn_link
Version Boost.python HelloWorld
#define BOOST_ALL_DYN_LINK#include <iostream>#include <boost/python.hpp>void hello(){ "hello, world" << std::endl;}BOOST_PYTHON_MODULE(helloworld){ usingnamespace boost::python; def("hello", &hello);}
- It should be noted that Boost_python_module (HelloWorld) must be consistent with the output PYD file name, change the target file name extension to. PYD in the project properties, configure the type selection DLL
- The generated. PYD file can be directly import in Python
Build Boost library under Windows (MSVC)