博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Installing C++ Boost on Microsoft Windows for Visual Studio .NET 2003/2005/Orcas
阅读量:6911 次
发布时间:2019-06-27

本文共 5425 字,大约阅读时间需要 18 分钟。

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 (~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 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://ftncl.baihongyu.com/

你可能感兴趣的文章
《人生的智慧》第一章 基本的划分
查看>>
ecshop商品颜色尺寸仿淘宝选择功能教程
查看>>
AJAX实用教程——开篇
查看>>
数据库插入数据返回当前主键ID值方法
查看>>
浅谈三层架构
查看>>
Linux下使用openssl生成证书
查看>>
java设计优化-享元模式
查看>>
Android 获取文件大小
查看>>
linux删除或隐藏命令历史记录history
查看>>
java.lang.OutOfMemoryError: Java heap space
查看>>
认证 (authentication) 和授权 (authorization) 的区别
查看>>
Linux查看磁盘空间大小命令
查看>>
计算机软件著作权查询网址
查看>>
一起谈.NET技术,.Net4.0 Parallel编程(四)Task 上
查看>>
自定义Status Bar的基本方法
查看>>
react动画难写?试试react版transformjs
查看>>
Chrome(12)中使用getComputedStyle获取透明度(opacity)返回字符串不同于其它浏览器...
查看>>
【汉字乱码】IE下GET形式传递汉字。
查看>>
SmartImageView
查看>>
《FineUI秘密花园》在线阅读与完整PDF版
查看>>