Build Boost library under Windows (MSVC)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.