zoukankan      html  css  js  c++  java
  • Installing C++ Boost on Microsoft Windows for Visual Studio .NET 2003/2005/Orcas

    Installing C++ Boost on Microsoft Windows for Visual Studio .NET 2003/2005/Orcas - visame的专栏 - 博客频道 - CSDN.NET

    Installing C++ Boost on Microsoft Windows for Visual Studio .NET 2003/2005/Orcas

    888人阅读 评论(0) 收藏 举报

    Boost Consultancy has created a wizard based installer for downloading and installing the correct version of Boost components on a Windows machine for Visual Studio .NET IDEs. The Installer simplifies the process of installation by getting rid of the time-consuming, and on rare occasions error-prone, process of compilation from the sources. But if you use any IDE other than Visual Studio .NET(even the old Visual Studio 6.0 IDE) then you need to use the typical Boost installation method(). Below is the procedure to install Boost for Visual Studio .NET IDEs using the Boost Installer for Windows.

    1. Download Boost Installer for Windows(~180K in size) from Boost Consultancy website. Run the installer. You will see the following license agreement displayed(Installer license).

      Installing Boost on Windows

      Read it and press "I Agree" if you agree to the terms. Another license agreement will be displayed next(Boost Libraries license).

      Installing Boost on Windows

      Read it too and press "I Agree" again if you agree to the terms.

    2. Based on your geographical location, you can select one of the nearest location from the provided list of mirror locations. Select one or leave the default selection to select a location randomly. Press "Next".

      Installing Boost on Windows

    3. The following dialog box allows one or more variants of Boost libraries to be selected for downloading and installing on your system. First select the complier to download Boost libraries for. If you have both Visual Studio .NET 2003 and 2005 versions installed, and so prefer to use Boost with both of them, then you can select both the compilers in the left pane("Compilers").

      Then select which variant(s) of Boost library binaries you want to install. If you have absolutely no idea what to select here, then go with "Multithread Debug, static runtime" among any others you want to select. Press "Next" after making your selection(s).

      Installing Boost on Windows

    4. The next dialog box prompts the user to select the components of Boost to be installed. You may consider including "Source and Documentation" if the download size is not a big concern for you. The same (but updated) documentation is always available at Boost Documentation page anyway.

      Installing Boost on Windows

    5. I prefer to select a destination folder path that doesn't contain any spaces or special characters in it. Accept the default path as shown below to use Boost with Microsoft products or get into the habit of always installing programming or Unix like tools in paths that don't contain any spaces in them, like: C:/boost/boost_1_34_1 or C:/programs/boost/boost_1_34_1. (MinGW, Eclipse etc will be very happy with paths like these.)

      Installing Boost on Windows

    6. Time to take a coffee break. Depending upon the download size and the speed of the Internet connection, the download and install process may take some time to finish. (To give you an idea, it downloaded ~90MB in around 30 minutes of time on my machine.)

      Installing Boost on Windows

    7. Installation is finished.

      Installing Boost on Windows

      Time to start testing the installation.

    Testing Boost Installation in Visual Studio .NET 2003/2005/Orcas

    Boost has two type of libraries : header-only(which are compiler independent) and compiled binary libraries.

    • Testing Boost Header-only libraries:
      1. Start the Microsoft Visual Studio .NET IDE and create a new C++ project in it(File -> New Project). select Visual C++ -> Win32 in the left pane and Win32 Console Application/Win32 Console Project in the right pane. Enter a name(BoostDemo) for the project and click OK.

        Testing Boost Installation in Visual Studio .NET

      2. Right-click on the project name and select Properties(or select Project->BoostDemo Properties). Select Configuration Properties -> C/C++ -> General in the left pane and type/select Boost installation root directory(C:/boost/boost_1_34_1) in "Additional Include Directories" field in the right pane.

        Testing Boost Installation in Visual Studio .NET

      3. Add the following code just above the _tmain() function(in the generated file - BoostDemo.cpp).
        C++:
        1. #include<iostream>
        2. #include<boost/any.hpp>

        Add the following code with in the _tmain() function:

        C++:
        1. boost::any a(5);
        2. a = 7.67;
        3. std::cout<<boost::any_cast<double>(a)<<std::endl;

        Testing Boost Installation in Visual Studio .NET

      4. Select Build -> Build Solution to build the project and, assuming the build completes successfully without any errors, select Debug->Start Debugging to run the program.
    • Testing Boost Compiled Binary Libraries
      1. First complete the Header-only test as described above. In the same project, right-click on the project name and select "Properties". Select Configuration Properties -> Linker in the left pane and type/select the Boost lib directory path(C:/boost/boost_1_34_1/lib) in "Additional Library Directories" field in the right pane.

        Testing Boost Installation in Visual Studio .NET

      2. Add the following code just above the _tmain() function
        C++:
        1. #include<boost/filesystem/operations.hpp>
        2. namespace bfs=boost::filesystem;

        Add the following code with in the _tmain() function:

        C++:
        1. bfs::path p("BoostDemo.cpp");
        2. if(bfs::exists(p))
        3.     std::cout<<p.leaf()<<std::endl;
      3. Build and run the program as before.

    I have tested the above procedure with the latest release of Visual Studio Orcas Beta too.

    A NOTE:

    If you have not selected static runtime libraries to be installed in Step 3 in the installation procedure above, you need to configure Visual Studio to link dynamically with the Boost dll files. Alternatively, add the following code at the top of the file:
    C++:
    1. #define BOOST_ALL_DYN_LINK
    2. #define BOOST_LIB_DIAGNOSTIC

    Also you need to add the path to the dlls(C:/boost/boost_1_34_1/lib) to the system PATH variable(Control Panel -> System -> Advanced System Settings -> Environment Variables) before running the programs. This has to be done only once.

    http://beans.seartipy.com/2007/08/20/installing-c-boost-on-microsoft-windows-for-visual-studio-net-20032005/

  • 相关阅读:
    GIS的发展
    ajax请求头加Token时发生的跨域(CORS)请求问题
    js 给定时间,如'20130830',换算和今天的天数差
    过程改进点滴需求调研经验之一
    昨天向PAM推荐的好书
    关于专人整理和分析需求
    走出开发混沌
    过程改进点滴需求调研经验之二
    代码重构注意事项
    插件框架内核完成
  • 原文地址:https://www.cnblogs.com/lexus/p/2855041.html
Copyright © 2011-2022 走看看