如何使用升压在Visual Studio 2010 [英] How to use Boost in Visual Studio 2010

查看:134
本文介绍了如何使用升压在Visual Studio 2010的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是如何在Visual Studio 2010中一个空的项目中使用升压一个很好的一步一步的解释。


解决方案

虽然的内特的回答已经是pretty好,我要它更具体扩大的要求,Visual Studio 2010中,并包括在其中需要外部库中的各种可选组件编译信息。

如果您正在使用头文件只能库,那么所有你需要做的是取消归档升压下载和设置环境变量。下面的指令集只,而不是在整个系统作为一个整体的Visual Studio的环境变量。注意:您只需要做一次。


  1. 取消归档的最新版本提升(1.47.0写作的)到您选择的目录(例如 C:\\ boost_1_47_0 )。

  2. 创建在Visual Studio中一个新的空项目。

  3. 打开属性管理器并展开您所选择的平台的配置之一。

  4. 选择&安培;右键点击 Microsoft.Cpp<平台>。用户,然后选择属性来打开属性页面进行编辑。

  5. 选择 VC ++目录在左侧。

  6. 编辑的包含目录部分以包含对您的提振源文件的路径。

  7. 如果需要为不同的平台,您所选择的6 -
  8. 重复步骤3。

如果你想使用需要建设提升的一部分,但没有的功能,需要外部的依赖关系,然后构建它相当简单。


  1. 取消归档的最新版本提升(1.47.0写作的)到您选择的目录(例如 C:\\ boost_1_47_0 )。

  2. 启动Visual Studio命令提示符为您所选择的平台,然后导航到提升为。

  3. 运行: bootstrap.bat 打造b2.exe(previously命名的bjam)

  4. 运行B2:


    • Win32的: B2 --toolset = MSVC-10.0 --build型=完整的阶段;

    • 64 B2 --toolset = MSVC-10.0 --build型=完整的体系结构= 86的地址模型= 64级


去散步/看电影或2 / ....

<醇开始=8>
从一组指令的6以上设置环境变量 -
  • 通过所有步骤2。
  • 编辑的库目录部分包含的路径Boost库的输出。 (默认为例子,上面的说明会 C:\\ boost_1_47_0 \\阶段\\ lib中重命名,如果你想拥有86和放大器首先移动的目录,由64面。方(如&LT; BOOST_PATH&GT; \\ lib目录\\ X86 &放大器; &LT; BOOST_PATH&GT; \\ lib目录\\ 64

  • 如果需要为不同的平台,您所选择的6 -
  • 重复步骤2。

    如果你想要的可选组件,那么你有更多的工作要做。它们是:


    • 了Boost.Iostreams bzip2的过滤器

    • 了Boost.Iostreams zlib过滤器

    • Boost.MPI

    • Boost.Python的

    • Boost.Regex ​​ICU支持

    了Boost.Iostreams bzip2的过滤器:


    1. 取消归档最新版本的bzip2库(1.0.6写作)的源文件到您选择的目录(如 C:\\ bzip2-1.0.6

    2. 按照第二套以上指令打造提升,但增加了选项 -sBZIP2_SOURCE =C:\\ bzip2-1.0.6运行在步骤b2时, 5。

    了Boost.Iostreams zlib过滤器


    1. 取消归档最新版本的zlib库(1.2.5写作)的源文件到您选择的目录(如 C:\\的zlib-1.2.5

    2. 按照第二套以上指令打造提升,但增加了选项 -sZLIB_SOURCE =C:\\的zlib-1.2.5运行在步骤b2时, 5。

    Boost.MPI


    1. 安装MPI分布如Microsoft计算群集包。

    2. 从第二组的上述说明建立升压3 -
    3. 按照步骤1。
    4. 编辑文件项目config.jam中目录&LT; BOOST_PATH&GT; 起因于运行引导。添加在读使用MPI线; (注意之前的空间';')。

    5. 从第二组指令遵​​循的步骤上面休息建设的推动作用。如果MPI安装的自动检测失败,那么你就需要寻找并修改相应的构建文件查找MPI在正确的地方。

    Boost.Python的


    1. 安装Python发行,如ActiveState的ActivePython的。确保Python安装在PATH。

    2. 要完全建立库的32位版本,需要32位的Python,同样为64位版本。如果您已经安装了这样的理由多个版本,你需要告诉B2在哪里可以找到特定版本以及何时使用哪一个。要做到这一点的一种方法是在目录中编辑文件项目config.jam中 &LT; BOOST_PATH&GT; 的导致运行的引导。添加以下两行调整为适合您的Python安装路径和放大器;版本(注意之前的空间';')

      使用python:2.6:C:\\\\ \\\\的Python \\\\ Python26蟒蛇;

      2.6:C:\\\\ \\\\的Python Python26-64 \\\\蟒蛇:::

      使用python&LT;地址模型&GT; 64;

      请注意,这种明确的Python规范目前导致MPI建立失败。所以你需要做一些独立的建筑,并没有规范建立的一切,如果你正在构建MPI为好。


    3. 请按照第二套以上说明建造的推​​动作用。


    Boost.Regex ​​ICU支持


    1. 取消归档的最新版本ICU4C库(4.8写作)的源文件到您选择的目录(如 C:\\ ICU4C-4_8 )。

    2. &LT打开Visual Studio解决方案; ICU_PATH方式&gt; \\源\\ ALLINONE

    3. 所有建设为调试和放大器;发布配置为您选择的平台。可以有 近期建设ICU4C的释放与Visual Studio 2010中的一个问题,当输出为调试和放大器;发布版本是在同一目录下(这是默认行为)。可能的解决方法是做一个建立所有(的调试版本说)然后做一个重建所有在第2的配置(如发布版本)。

    4. 如果建立针对x64,你需要运行x64操作系统,因为后期的构建涉及到运行一些,它的构建64位应用程序的步骤。

    5. 当你完成有选择地删除源目录。

    6. 按照第二套以上说明打造提升,但增加了选项 -sICU_PATH =:在第5步运行时B2C \\ ICU4C-4_8

    What is a good step by step explanation on how to use Boost in an empty project in Visual Studio 2010.

    解决方案

    While Nate's answer is pretty good already, I'm going to expand on it more specifically for Visual Studio 2010 as requested, and include information on compiling in the various optional components which requires external libraries.

    If you are using headers only libraries, then all you need to do is to unarchive the boost download and set up the environment variables. The instruction below set the environment variables for Visual Studio only, and not across the system as a whole. Note you only have to do it once.

    1. Unarchive the latest version of boost (1.47.0 as of writing) into a directory of your choice (e.g. C:\boost_1_47_0).
    2. Create a new empty project in Visual Studio.
    3. Open the Property Manager and expand one of the configuration for the platform of your choice.
    4. Select & right click Microsoft.Cpp.<Platform>.user, and select Properties to open the Property Page for edit.
    5. Select VC++ Directories on the left.
    6. Edit the Include Directories section to include the path to your boost source files.
    7. Repeat steps 3 - 6 for different platform of your choice if needed.

    If you want to use the part of boost that require building, but none of the features that requires external dependencies, then building it is fairly simple.

    1. Unarchive the latest version of boost (1.47.0 as of writing) into a directory of your choice (e.g. C:\boost_1_47_0).
    2. Start the Visual Studio Command Prompt for the platform of your choice and navigate to where boost is.
    3. Run: bootstrap.bat to build b2.exe (previously named bjam).
    4. Run b2:

      • Win32: b2 --toolset=msvc-10.0 --build-type=complete stage ;
      • x64: b2 --toolset=msvc-10.0 --build-type=complete architecture=x86 address-model=64 stage

    Go for a walk / watch a movie or 2 / ....

    1. Go through steps 2 - 6 from the set of instruction above to set the environment variables.
    2. Edit the Library Directories section to include the path to your boost libraries output. (The default for the example and instructions above would be C:\boost_1_47_0\stage\lib. Rename and move the directory first if you want to have x86 & x64 side by side (such as to <BOOST_PATH>\lib\x86 & <BOOST_PATH>\lib\x64).
    3. Repeat steps 2 - 6 for different platform of your choice if needed.

    If you want the optional components, then you have more work to do. These are:

    • Boost.IOStreams Bzip2 filters
    • Boost.IOStreams Zlib filters
    • Boost.MPI
    • Boost.Python
    • Boost.Regex ICU support

    Boost.IOStreams Bzip2 filters:

    1. Unarchive the latest version of bzip2 library (1.0.6 as of writing) source files into a directory of your choice (e.g. C:\bzip2-1.0.6).
    2. Follow the second set of instructions above to build boost, but add in the option -sBZIP2_SOURCE="C:\bzip2-1.0.6" when running b2 in step 5.

    Boost.IOStreams Zlib filters

    1. Unarchive the latest version of zlib library (1.2.5 as of writing) source files into a directory of your choice (e.g. C:\zlib-1.2.5).
    2. Follow the second set of instructions above to build boost, but add in the option -sZLIB_SOURCE="C:\zlib-1.2.5" when running b2 in step 5.

    Boost.MPI

    1. Install a MPI distribution such as Microsoft Compute Cluster Pack.
    2. Follow steps 1 - 3 from the second set of instructions above to build boost.
    3. Edit the file project-config.jam in the directory <BOOST_PATH> that resulted from running bootstrap. Add in a line that read using mpi ; (note the space before the ';').
    4. Follow the rest of the steps from the second set of instructions above to build boost. If auto-detection of the MPI installation fail, then you'll need to look for and modify the appropriate build file to look for MPI in the right place.

    Boost.Python

    1. Install a Python distribution such as ActiveState's ActivePython. Make sure the Python installation is in your PATH.
    2. To completely built the 32-bits version of the library requires 32-bits Python, and similarly for the 64-bits version. If you have multiple versions installed for such reason, you'll need to tell b2 where to find specific version and when to use which one. One way to do that would be to edit the file project-config.jam in the directory <BOOST_PATH> that resulted from running bootstrap. Add in the following two lines adjusting as appropriate for your Python installation paths & versions (note the space before the ';').

      using python : 2.6 : C:\\Python\\Python26\\python ;

      using python : 2.6 : C:\\Python\\Python26-x64\\python : : : <address-model>64 ;

      Do note that such explicit Python specification currently cause MPI build to fail. So you'll need to do some separate building with and without specification to build everything if you're building MPI as well.

    3. Follow the second set of instructions above to build boost.

    Boost.Regex ICU support

    1. Unarchive the latest version of ICU4C library (4.8 as of writing) source file into a directory of your choice (e.g. C:\icu4c-4_8).
    2. Open the Visual Studio Solution in <ICU_PATH>\source\allinone.
    3. Build All for both debug & release configuration for the platform of your choice. There can be a problem building recent releases of ICU4C with Visual Studio 2010 when the output for both debug & release build are in the same directory (which is the default behaviour). A possible workaround is to do a Build All (of debug build say) and then do a Rebuild all in the 2nd configuration (e.g. release build).
    4. If building for x64, you'll need to be running x64 OS as there's post build steps that involves running some of the 64-bits application that it's building.
    5. Optionally remove the source directory when you're done.
    6. Follow the second set of instructions above to build boost, but add in the option -sICU_PATH="C:\icu4c-4_8" when running b2 in step 5.

    这篇关于如何使用升压在Visual Studio 2010的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆