zoukankan      html  css  js  c++  java
  • boost 在code blocks 中的 配置(转)

    下面的至少在 boost_1_36_0和 boost_1_46_1中成功实现,boost_1_47_0中还是不行

    1.

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

    // 如果要编译自己的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 (自行下载boost-jam-3.1.16-1-ntx86.zip)

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

    //============编译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库编译。

    2. 在code blocks 中的 配置

                

    2.1 配置boost
    打开 code::blocks -> Settings -> Compiler and debugger… -> Search directory -> Add -> … [添加C:\boost\boost_1_37_0] -> OK

    2.2 配置添加lib
    打开 code::blocks -> Settings -> Compiler and debugger… -> Linker Settings -> Add -> … [需要什么就添加什么,例如boost\lib\boost_thread-mgw43-mt.lib]

    2.3 测试boost
    //简单测试,仅仅测试是否安装正确,而不是测试boost完整性
    //以下程序的功能是从终端接受一个整数序列,然后乘以3再输出到终端

    //test1.cpp
    #include <iostream>
    #include <iterator>
    #include <algorithm>
    #include <boost/lambda/lambda.hpp>
    int main()
    {
    using namespace boost::lambda;
    typedef std::istream_iterator<int> in;
    std::for_each(in(std::cin), in(), std::cout << (_1 * 3) << " ");
    }
    
    //以下程序在终端输出[2](2,8)
    //test2.cpp
    #include <boost/numeric/ublas/vector.hpp>
    #include <boost/numeric/ublas/matrix.hpp>
    #include <boost/numeric/ublas/io.hpp>
    #include <iostream>
    
    using namespace boost::numeric::ublas;
    
    
    int main ()
    {
    vector<double> x (2);
    x(0) = 1; x(1) = 2;
    matrix<double> A(2, 2);
    A(0, 0) = 0; A(0, 1) = 1;
    A(1, 0) = 2; A(1, 1) = 3;
    vector<double> y = prod(A, x);
    std::cout << y << std::endl;
    return 0;
    }
    

    主要参考http://www.cnblogs.com/bylikai/archive/2011/01/15/1936293.html

              http://www.cnblogs.com/bylikai/archive/2011/01/15/1936293.html

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

  • 相关阅读:
    Appium之启动第一个App
    Appium简介
    C语言-malloc,calloc,realloc 函数的使用(堆空间的使用)
    C语言-const 修饰符,static 和 extern修饰符
    C语言-字符串与指针,fgets 函数,fputs 函数
    C语言- 指针(初始化,作用,指针与整数的加减法,指针与指针的减法,指针与指针之间的比较,指针与数组,函数的关系,中括号的本质)
    C语言-字符串
    C语言-数组
    C语言-类型说明符 long,short,unsigned,signed
    C语言-char 类型基本概念
  • 原文地址:https://www.cnblogs.com/hitwtx/p/2119674.html
Copyright © 2011-2022 走看看