zoukankan      html  css  js  c++  java
  • Code::Blocks中安装boost (windows平台下)

    网上关于boost的安装 版本不少,但是好像都是关于 拷贝 boost-jam-3.1.16-1-ntx86.zip下的 bjam.exe 到 boost解压路径 ***\boost_1_45_0\下,然后 就开始编译boost了,

    如:

    http://www.d2school.com/bhcpp_book/2_5.php

    //===================================================================

    // 如果要编译自己的bjam.exe (正常情况下,都需要编译自己的 bjam.exe )  查看bjam.exe 编译,

    • boost 1.36.0 的源代码压缩文件,推荐下载 7zip 版本:boost_1_36_0.7z”。
    • boost 编译工具,请选择windows下的可执行文件:boost-jam-3.1.16-1-ntx86.zip  //如果自己编译bjam.exe 就不需要下载了。编译自己的bjam.exe 文件

    下载后,得到源代码压缩文件,如果是7zip格式的“boost_1_36_0.7z”,约25M,解压后,将迅速变为175M,但这仅仅是源代码及文档的大小,在编译过程中,所需的空间更是惊人,请您保证解压缩后文件所在的磁盘驱动器,至少有5个G的可用空间。

    boost 的编译工具,可以根据需要,将编译之后库文件,及不需要编译的头文件,统一复制到指定的目录,这样有利于我们得到一个“干净”的boost编译结果目录,本书将采用此方法。

    下面,我们假设boost_1_36_0.7z被解压到“X:\tmp \boost_1_36_0”目录下,其中“X:”表示您选用的磁盘驱动器盘符, “tmp”是我们事先创建的文件夹,而 “boost_1_36_0”则在解压以后得到。我们把“X:\tmp\ boost_1_36_0”称为“boost安装源路径”。

    接下来,假设我们希望它boost安装到“E:\ boost_1_36_0”目录下,请事先创建好这个文件夹,我们把这个路径,称为“boost安装目标路径”。

    请解压“boost-jam-3.1.16-1-ntx86.zip”文件,得到bjam.exe,将它复制到boost安装源路径,即“X:\tmp\boost_1_36_0”之下。

     

    //===================================================================

    //============编译boost

     

    步骤1:打开“开始”菜单,选择“运行”,输入cmd,进入控制台窗口,然后在其内通过cd命令,切换到boost安装源路径下。本例中为:

    “X:\tmp\boost_1_36_0”,则过程如下:

    X: (回车)

    cd tmp\boost_1_36_0 (回车)

    步骤2:继续上步,请在控制台内输入:

    bjam --show-libraries (回车)

    步骤3:正确情况下,将看到以下输出内容:

    The following libraries require building:

    - date_time

    - filesystem

    - function_types

    - graph

    - iostreams

    - math

    - mpi

    - program

    _options

    - python

    - regex

    - serialization

    - signals

    - system

    - test

    - thread

    - wave

    步骤4:这里列出的是所有需要编译的boost模块,但我们将放弃对以下模块的编译: wave、mpi、 python、math、graph。这些模块的具体含义,大家如有需要,请自行查明。

    步骤5:继续上步,在控制台内输入:

    bjam install --toolset=gcc --prefix="E:\boost_1_36_0" debug --without-wave --without-mpi --without-python --without-math --without-graph (回车)

    步骤6:请特别注意其中加粗部分,更换为您自己的“boost安装目标路径”。其它部分作如下说明:

    步骤7:-- 是两个连续的减号,=前后均不能夹带空格,除路径之外,参数都是小写字母。

    步骤8:--toolset 表示采用gcc编译。这里指的mingw32下的gcc。因此,要正确编译boost,请您一定事先已完成2.1小节中,有关Code::Blocks下mingw32环境的安装。

    步骤9:debug表示我们首先编译“调试版”。

    步骤10:多个 --without 指定了所要放弃编译的模块。

    步骤11:回车后,控制台内将出现大量看似奇奇怪怪地文字,最后能看到以下内容,就表示成功完成本步:

    ...failed updating 2 targets.

    ...skipped 31 targets...

    ...updated 341 targets...

    步骤12:继续上步,在控制台内输入:

    bjam install --toolset=gcc --prefix="E:\boost_1_36_0" release --without-wave --without-mpi --without-python --without-math --without-graph (回车)

    步骤13:改变的是“debug”更换为“release”。回车后开始发行版的boost库编译。

     

    //=====================================================

    //======编译自己的bjam.exe 文件

    在boost解压路径下:D:\Program Files\boost\boost_1_45_0

    1.首先确保D:\Program Files\boost\boost_1_45_0 目录下有 下面脚本文件:

    bootstrap.bat     //windows使用, 用来编译自己的 bjam.exe 使用

    bootstrap.sh      //unix,linux系统下使用; shell

     

     

    2. 打开文件夹:.\tools\build\v2  该文件夹有2个配置文件:

       site-config.jam

       user-config.jam

       一般修改 user-config.jam 文件内容即可,

       用记事本打开 user-config.jam 文件,然后选择你自己的 编译器, 如我选择 gcc, 即

       using gcc ;

       只要将你选择的编译器类型 放开即可( 去掉编译器前的 # )


      

    # ------------------
    # GCC configuration.
    # ------------------

    # Configure gcc (default version).
    using gcc ;

    # Configure specific gcc version, giving alternative name to use.
    # using gcc : 3.2 : g++-3.2 ;



    # -------------------
    # MSVC configuration.
    # -------------------

    # Configure msvc (default version, searched for in standard locations and PATH).
    # using msvc ;

    # Configure specific msvc version (searched for in standard locations and PATH).
    # using msvc : 8.0 ;


    # ----------------------
    # Borland configuration.
    # ----------------------
    # using borland ;


    # ----------------------
    # STLPort configuration.
    # ----------------------

    #   Configure specifying location of STLPort headers. Libraries must be either
    # not needed or available to the compiler by default.
    # using stlport : : /usr/include/stlport ;

    # Configure specifying location of both headers and libraries explicitly.
    # using stlport : : /usr/include/stlport /usr/lib ;


    # -----------------
    # QT configuration.
    # -----------------

    # Configure assuming QTDIR gives the installation prefix.
    # using qt ;

    # Configure with an explicit installation prefix.
    # using qt : /usr/opt/qt ;

     

     

    3. 配置完编译器后,双击 bootstrap.bat 即可在 当前目录下生成  bjam.exe

    重回   编译boost : 步骤5

     

    具体如何使用boost可以参考其他的文章;




     


     

  • 相关阅读:
    Android 下压缩图片—微弱失真
    android中ViewHolder通用简洁写法
    Android裁剪固定大小头像的功能
    Android进度加载的Loading效果
    GitHub开源项目总结
    Android 实现emoji表情的demo
    vim 高级使用技巧第二篇
    android apk 防止反编译技术第一篇-加壳技术
    Android Metro风格的Launcher开发系列第二篇
    FFMPEG高级编程第一篇:环境搭建及编译
  • 原文地址:https://www.cnblogs.com/bylikai/p/1936293.html
Copyright © 2011-2022 走看看