• 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.

  • 相关阅读:
    面试:div水平垂直居中方案--img自适应
    面试:call、apply、bind原理以及自己手写简易模式
    面试之:判断js类型的方式总结
    git的项目完整操作
    vue3.x版本新建项目相关知识和注意事项
    面试常问平时项目中【Date】的常用操作方法总结
    面试常问平时项目中【Math】的常用操作方法总结
    面试常问平时项目中数组【Array】的常用操作方法总结
    面试常问平时用的对象【Object】的创建方式和常用的对象方法总结
    优化无限列表性能vue-virtual-scroll-list【测试90w条数据】
  • 原文地址:https://www.cnblogs.com/rogerroddick/p/2846713.html
Copyright © 2020-2023  润新知