How to use Boost in Visual Studio 2010

后端 未结 13 1081
情歌与酒
情歌与酒 2020-11-22 07:14

What is a good step by step explanation on how to use the Boost library in an empty project in Visual Studio?

13条回答
  •  北恋
    北恋 (楼主)
    2020-11-22 07:20

    A minimalist example to get you started in Visual Studio:

    1.Download and unzip Boost from here.

    2.Create a Visual Studio empty project, using an example boost library that does not require separate compilation:

    #include 
    #include 
    
    using namespace std;  
    using namespace boost;  
    
    int main()  
    {  
        unsigned int arr[5] = { 0x05, 0x04, 0xAA, 0x0F, 0x0D };  
    
        cout << format("%02X-%02X-%02X-%02X-%02X")  
                % arr[0]  
                % arr[1]  
                % arr[2]  
                % arr[3]  
                % arr[4]  
             << endl;  
    }  
    

    3.In your Visual Studio project properties set the Additional Include Directories:

    Project Properties

    For a very simple example:

    How to Install the Boost Libraries in Visual Studio

    If you don't want to use the entire boost library, just a subset:

    Using a subset of the boost libraries in Windows

    If you specifically want to now about the libraries that require compilation:

    How to use the Boost compiled libraries in Windows

提交回复
热议问题