zoukankan      html  css  js  c++  java
  • C++ boost usage

    Install BOOST

    1. Build from source code

    Download the new release package from boost official website

    For windows, download zip or 7z format and unpack it using 7zip or winrar

    For linux/mac os, download tar.gz or tar.bz2, and unpack it by these command.

    tar zxf ....tar.gz -C ./ or tar jxf ...tar.bz2 -C ./

    cd the boost_1_xx_x

    for windows,  run bootstrap.bat to create bjam and b2

    for linux/mac os, run ./bootstrap.sh to create bjam and b2

    build the library for different compiler:

    for msvc

    mkdir msvc # store the msvc libraries

    ./bjam toolset=msvc-10.0 --build-dir=msvc --build-type=complete –stagedir=msvc --with-filesystem –disablefilesystem2

    其中build-dir是临时编译文件,而stagedir是最后使用的lib/dll文件路径,如果不是硬盘空间紧缺,建议保留build-dir里的文件,想上述命令,如果想在win32或者x64在windows下可以分别使用如下指令

    win32> ./bjam toolset=msvc-10.0 --build-dir=msvc/win32 --build-type=complete --stagedir=msvc/Win32 --with-filesystem –disablefilesystem2

    x64> ./bjam toolset=msvc-10.0 --build-dir=msvc/x64 --build-type=complete --stagedir=msvc/x64 --with-filesystem –disablefilesystem2 address-model=64

    注意:如果是编译64位,需要在vs64位命令行窗口中进行,同时需要加上address-model=64这个编译选项,否则在链接库的时候将会出现LNK2019的错误

    通常build-dir建立出来是指定路径下/boost/文件夹,而stagedir则是指定路径/lib/

    for gcc

    mkdir gcc # store the gcc libraries

    ./bjam toolset=gcc --build-dir=gcc --build-type=complete --stagedir=gcc --with-filesystem --disablefilesytem2 --layout=versioned

    for darwin

    mkdir darwin # store the darwin libraries

    ./bjam toolset=darwin --build-dir=darwin --build-type=complete --stagedir=darwin --with-filsystem --disablefilesystem2 --layout=versioned

    2. Use macport to install

    download the macport from officail website and then install it.

    Run these command to install it.

    sudo port selfupdate #update the software tree

    port search boost #check whether contains boost

    port info boost #check details about boost

    sudo port install boost

    the boost will be installed under /opt/local/include for header file, /opt/local/ilb for the library. If you want to change the path, need to build the source code using --prefix.

  • 相关阅读:
    注意身体
    用生命去战斗
    来到华师,一切清零
    linux fork()函数 转载~~~~
    小端大端
    位域
    内存泄漏(memory leak)和内存溢出
    stack,heap的区别
    内存管理简便复习总结
    虚函数&&虚继承
  • 原文地址:https://www.cnblogs.com/rogerroddick/p/2846713.html
Copyright © 2011-2022 走看看