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/

posted on 2013-01-10 16:29  lexus 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/lexus/archive/2013/01/10/2855041.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值