zoukankan      html  css  js  c++  java
  • Boost的VS开发环境搭建

    1. 下载并解压Boost C++ Libs

    下载地址:

    SourceForge:http://sourceforge.net/projects/boost/files/boost/1.48.0/

    Boost Official:http://www.boost.org/users/history/version_1_48_0.html (实际上也是从SourceForge下载)

    解压到 E:oost_1_48_0

    发现上面的版本编译不出64位,只有32位,哪怕指定了--address-model=64

    可以去https://www.boost.org/users/history/ 这边下一个boost_1_48_0,在试试看

    推荐使用boost_1_66_0 能够生成64位和32位的

    2. 编译

     我们需要对所有 编译器版本(Visual Studio 20** Command Prompt对应的编译器版本(区分32和64位)+toolset的指定)+32/64版本+debug/release版本 各执行一次编译

    打开VS2008,在菜单栏“工具”选择“Visual Studio 2008 Command Prompt”,在弹出的控制台中,输入:

    C:UsersMichael>E:  
    E:>cd boot_1_48_0  
    E:>bootstrap.bat
    E:>b2 stage --build-type=complete --toolset=msvc-9.0 --address-model=32 --variant=debug --threading=multi --link=static --runtime-link=shared --build-dir=".in.v2.vc2008_x86_d" --stagedir="."
    E:>b2 stage --build-type=complete --toolset=msvc-9.0 --address-model=32 --variant=release --threading=multi --link=static --runtime-link=shared --build-dir=".in.v2.vc2008_x86_r" --stagedir="."

    在菜单栏“工具”选择“Visual Studio 2008 x64 Win64 Command Prompt”,在弹出的控制台中,输入:

    C:UsersMichael>E:  
    E:>cd boot_1_48_0  
    E:>bootstrap.bat
    E:>b2 stage --build-type=complete --toolset=msvc-9.0 --address-model=64 --variant=debug --threading=multi --link=static --runtime-link=shared --build-dir=".in.v2.vc2008_x64_d" --stagedir="."
    E:>b2 stage --build-type=complete --toolset=msvc-9.0 --address-model=64 --variant=release --threading=multi --link=static --runtime-link=shared --build-dir=".in.v2.vc2008_x64_r" --stagedir="."

      每一条b2大概执行一个小时。且每一条b2,虽然32位、64位、debug、release不同的组合编译设置,但编译出来的东西是一样的,为什么?

        因为--build-type=complete,在boost_1_66_0中,决定了可以编译所有的--threading、--runtime-link、--variant、--address-model、--link;在boost_1_48_0中,决定了可以编译所有的--variant、--link,但--threading=multi、--runtime-link=shared、--address-model=32(可以通过查看编译出来的dll是否为32位还是64位)。但是--toolset默认使用系统安装的最高版本的VC,跟用例如Visual Studio的Visual Studio 2008 x64 Win64 Command Prompt命令提示符没关系。

     中间文件都在bin.v2*目录下

    bootstrap.bat用来完成编译前的配置工作。如生成bjam.exe和b2.exe  bjam.exe 是老版本,b2是bjam的升级版本,都是可行的

    其中“--toolset=msvc-9.0”表示编译成VS 9.0版本,因为VS 2008为VS 9.0版本,如果是VS 2010,则用“--toolset=msvc-10.0”参数。

    (1)b2 stage --build-type=complete --toolset=msvc-10.0 或者(2)bjam.exe stage --build-type=complete --toolset=msvc-10.0。,推荐使用(1)  

     complete是个生成所有当前系统上有的编译器的调试版和发行版的静态库和动态库的过程。最后大小在windows上是5G样子。

     

    如果:

    目标位置如./stage/lib下有存在的结果文件了,则直接跳过编译和跳过拷贝操作。

    目标位置如./stage/lib下没有存在的结果文件,则直接跳过编译,但执行从./bin.v2文件夹下拷贝相应的文件操作。

    ./bin.v2文件夹不存在,则会执行编译。所以在每次编译的时候,最好要把这个文件夹删除,且把./stage/lib这个已经存在的文件夹改名。

     

    编译是很漫长的过程,如果你只需要使用Boost库的一部分,可以选择性地编译。比如你只想用system,thread库,则输入:

    E:>bjam --toolset=msvc-9.0 --with-system -with-thread  

    下面详细解释一下每个参数的含义:

    stage/install:stage 表示只生成库(dll和lib),install还会生成包含头文件的include目录。本人推荐使用stage,因为install生成的这个include 目录实际就是boost安装包解压缩后的boost目录(E:SDKoost_1_39_0oost,只比include目录多几个非hpp文件,都很小),所以可以直接使用,而且不同的IDE都可以使用同一套头文件,这样既节省编译时间,也节省硬盘空间。

    toolset:指定编译器,可选的如borland、gcc、msvc(VC6)、msvc-7.1(vs2003)、msvc-8.0(vs2005)、msvc-9.0(vs2008)、msvc-10.0(VS20010)、msvc-12.0(VS20013)等。如果不指定,则生成某一个系统默认的编译器版本。跟从Visual Studio 20** Command Prompt对应的编译器版本没关系。

    --without-/--with-:选择不编译/编译哪些库。因为python、mpi等库我都用不着,所以排除之。另外,wave、graph、math、regex、test、 program_options、serialization、signals这几个库编出的静态lib都非常大,所以不需要的也可以without掉。这可以根据各人需要选择,默认是全部编译

    --stagedir/--prefix:stage 时使用stagedir,install时使用prefix(--prefix跟--stagedir连用时,只有--prefix起作用),表示编译生成文件的路径。推荐给不同的IDE指定不同的目录,如VS2010对应的是 E:SDKoost_1_46_1vc10,VC6对应的是E:SDKoost_1_45_0vc6,否则都生成到一个目录下面,难以管理。如果使用了install参数,那么还将生成头文件目录,vc9如果--prefix=E:SDKoost_1_46_1vc9 对应的就是E:SDKoost_1_46_1vc9 includeoost-1_66 (其下有boost目录),vc6类似(光这路径都这样累赘,还是使用stage好)。

    --stagedir=".invc12_x86" --stagedir=".invc12_x64" 默认是./stage

    --build-dir:编译生成的中间文件的路径。这个本人这里没用到,默认就在根目录(E:SDKoost_1_46_1)下,目录名为bin.v2,等编译完成后可将这个目录全部删除(没用了),所以不需要去设置。

    --build-type

      默认是minimal, on Windows, these are static multithreaded libraries in debug and release modes, using shared runtime; on Linux, these are static and shared multithreaded libraries in release mode.

      Complete, build all possible variations.(就是说build所有支持的编译选项)

    --variant:决定编译什么版本。variant=debug variant=release

    debug/release:?编译debug/release版本。一般都是程序的debug版本对应库的debug版本,所以两个都编译。如果不指定,则两种方式都生成;也可以全部指定如: debug release  注意:linux上只能同时使用一种且不带--variant=

    link:生成动态链接库/静态链接库。生成动态链接库需使用shared方式,生成静态链接库需使用static方式。一般boost库可能都是以static方式编译,因为最终发布程序带着boost的dll感觉会比较累赘。如果不指定,则两种方式都生成。

    runtime-link:动态/静态链接C/C++运行时库。同样有shared和static两种方式。如果不指定,则两种方式都生成。一般都是使用shared

    这样runtime-link和link一共可以产生4种组合方式,各人可以根据自己的需要选择编译。一般link只选static的话,只需要编译2种组合即可,即link=static runtime-link=shared(推荐)和link=static runtime-link=static。

    threading:单/多线程编译。一般都写多线程程序,当然要指定threading=multi方式了(默认);如果需要编写单线程程序,那么还需要编译单线程库,可以使用single方式。

    --address-model:默认生成32位的平台库,加入address-model=64属性才能生成64位的DLL。

    --architecture:architecture=x86 (32位和64位都用这个)

    --help:

    3. 配置VS2008环境

    在菜单栏的“工具”——“选项”——“项目和解决方案”——“VC++目录”,“平台”选择“Win32”。

    “显示以下内容的目录”选择“包含文件”,点击“新建”按钮,文件夹选择“Eoost_1_48_0”。

    “显示以下内容的目录”选择“库文件”,点击“新建”按钮,文件夹选择“E:oost_1_48_0stagelib”。

    4.编写代码测试

    注:如果编写的测试代码出现类似错误”无法打开包括文件:“boost/regex.hpp”: No such file or directory” 说明附件包含目录出现错误,这时要纠正包含目录。

    如果在下还有incude目录,我们只需包含includes目录就加载了相关头文件,如果没有,如上加载总目录,让编译器自己找。

    附加:在第2步的时候,如果将执行指令里面的“stage”改成”install”,则会生成include指令。

     1 #include<iostream>
     2 #include <boost/regex.hpp>
     3 using namespace std;
     4 
     5 int main()
     6 {
     7     // 3 digits, a word, any character, 2 digits or "N/A", 
     8     // a space, then the first word again
     9     boost::regex reg("\d{3}([a-zA-Z]+).(\d{2}|N/A)\s\1");
    10 
    11     std::string correct="123Hello N/A Hello";
    12     std::string incorrect="123Hello 12 hello";
    13 
    14     assert(boost::regex_match(correct,reg)==true);
    15     assert(boost::regex_match(incorrect,reg)==false);
    16     cout<<"Hello Boost !"<<endl;
    17 }

    参见:https://www.cnblogs.com/zhcncn/p/3950477.html

    所得到的结果如下表所示:

    序号 link runtime-link 生成物 备注
    1 static static

    libboost_date_time-vc120-mt-sgd-1_56.lib

    libboost_date_time-vc120-mt-s-1_56.lib

     
    2 static shared

    libboost_date_time-vc120-mt-gd-1_56.lib

    libboost_date_time-vc120-mt-1_56.lib

    与5结果相同
    3 shared shared

    boost_date_time-vc120-mt-gd-1_56.dll

    boost_date_time-vc120-mt-gd-1_56.lib

    boost_date_time-vc120-mt-1_56.dll

    boost_date_time-vc120-mt-1_56.lib

     
    4 shared static 报错,无法编译  
    5 使用缺省 使用缺省

    libboost_date_time-vc120-mt-gd-1_56.lib

    libboost_date_time-vc120-mt-1_56.lib

    与2结果相同

    并且在省略debug release时,debug release版本都编译

    6 使用--build-type=complete

    boost_date_time-vc120-mt-gd-1_56.dll

    boost_date_time-vc120-mt-gd-1_56.lib

    boost_date_time-vc120-mt-1_56.dll

    boost_date_time-vc120-mt-1_56.lib

    libboost_date_time-vc120-mt-sgd-1_56.lib

    libboost_date_time-vc120-mt-s-1_56.lib

    libboost_date_time-vc120-mt-gd-1_56.lib

    libboost_date_time-vc120-mt-1_56.lib

    libboost_date_time-vc120-s-1_56.lib

    libboost_date_time-vc120-sgd-1_56.lib

     --build-type=complete时,可以看到link,runtime-link的

    3种组合下debug, release的多线程版本都生成出来了,

    除此之外,还生成了link=static,runtime-link=static的debug, release的单线程版本

    从上面的结果可以看到,link和runtime-link的缺省配置是 link=static runtime-link=shared,所以我们可以使用 (b2 stage --toolset=msvc-12.0 --with-date_time --stagedir="E:eCodeoost_1_56_0invc12_2")命令行来编译boost。

    另外,我们还可以分析一下 boost 库的命名特点:【2】

    (1)以“lib”开头的是“link=static”版本(静态链接库版本,没有dll),而直接以“boost”开头的是“link=shared”版本(动态链接库版本,包含lib和dll)。

    (2)所有的库都含有"boost"前缀。

    (3)紧随其后的是boost库名称(比如date_time库)。

    (4)然后是编译器的版本,与库名称之间以"-"而不是下划线"_"分隔(比如 -vc120)。

    (5)有“mt”的为“threading=multi”版本,没有的则是“threading=single”版本。

    (6)有“s”的为“runtime-link=static”版本,没有的则是“runtime-link=shared”版本。

    (7)有“gd”的为debug版本,没有的则是release版本。

    (8)所有的库都含有boost库的版本号结尾(比如1_56,其中的"."以下划线"_"代替)

    3. link, runtime-link 组合分析

    文章【2】给出了link,runtime-link的具体作用分析。

    假设一个库A依赖于库B,我们自己的程序client依赖于库A,即:

    那么,link指的是client->A,runtime-link指的是A -> B

    配置

    链接过程

    运行时需要的文件

    link=static

    runtime-link=static

    client通过A.a (A.lib)静态包含A;

    A通过B.a (B.lib)静态包含B;

    不关 .so .dll的事

    client

    link=static

    runtime-link=shared

    client通过A.a (A.lib)静态包含A;

    在运行时,client要动态调用B.so (B.dll)

    client

    B.so (B.dll)

    link=shared

    runtime-link=shared

    client会包含A.a (A.lib);

    A会包含 B.a (B.lib);

    但都只保存动态库的真正实现的stub,运行时通过stub去动态加载 A.so (A.dll), B.so (B.dll) 中的实现

    client

    A.so (A.dll)

    B.so (B.dll)

    link=shared

    runtime-link=static

    client会包含A.a (A.lib),但只包含真正实现的stub;

    A通过B.a (B.lib)静态包含B;

    运行时,client会动态调用A.so (A.dll)

    client

    A.so (A.dll)

    3. 配置

    包含头文件的Include路径:E:eCodeoost_1_56_0

    包含库文件的链接路径:E:eCodeoost_1_56_0invc12lib

    (1)可以设置为仅用于当前project

    选中当前project->Properties->Configuration Properties->C/C++->General: Additional Include Directories: 设置 E:eCodeoost_1_56_0

    选中当前project->Properties->Configuration Properties->Linker->General: Additional LibraryDirectories: 设置 E:eCodeoost_1_56_0invc12lib

    (2)可设置为仅用于当前Solution

    选中当前project->Properties->Configuration Properties->VC++ Directories:

    Include Directories: 设置 E:eCodeoost_1_56_0

    LibraryDirectories: 设置 E:eCodeoost_1_56_0invc12lib

    (3)可设置为OS当前用户下的VC++环境(当前用户下VC++所创建的所有Solution)

    在某个已打开的工程下,切换到Property Manager 选项卡,然后然后展开当前工程的properties配置,打开Microsoft.Cpp.Win32.User

    选择Common Properties->VC++ Directories:

    Include Directories: 设置 E:eCodeoost_1_56_0

    LibraryDirectories: 设置 E:eCodeoost_1_56_0invc12lib

    这样设置的仅在Win32编译选项下起作用,x64编译选项需要另外配置x64的properties sheet。

    (4)可设置为OS所有用户下的VC++环境

    可以编辑 Microsoft.Cpp.Default.props 、Microsoft.Cpp.props 。这里就不介绍了。

    4. 测试

    使用文章【3】中date_time计时函数。创建一个Win32 console 工程,然后copy下面代码

    复制代码
    //#define BOOST_DATE_TIME_SOURCE
    #include <iostream>
    #include <boost/date_time/gregorian/gregorian.hpp>
    #include <boost/date_time/posix_time/posix_time.hpp>
    using namespace std;
    using namespace boost::gregorian;
    using namespace boost::posix_time;
    
    /************************************************************************
    创建微秒级的计时器
    ************************************************************************/
    
    template <class T = microsec_clock>
    class MyTimer
    {
    private:
        ptime m_startTime;
    
    public:
        MyTimer()
        {
            Restart();
        }
    
        void Restart()
        {
            m_startTime = T::local_time();
        }
    
    
        void Elapsed()
        {
            cout << T::local_time() - m_startTime << endl;
        }
    };
    
    
    int main()
    {
        MyTimer<microsec_clock> t;
        for(int i = 0; i < 100; ++i)
        {
            cout << "hello" << endl;
        }
        t.Elapsed();
    }
    复制代码

    注意开头的宏 “#define BOOST_DATE_TIME_SOURCE” 注掉了。若启用这个宏定义,则默认由编译器重新编译嵌入的头文件;若不启用这个宏定义,则表示使用系统已编译好的date_time库。

    (1)禁用#define BOOST_DATE_TIME_SOURCE 宏,然后将 libboost_date_time-vc120-mt-gd-1_56.lib 从 E:eCodeoost_1_56_0invc12lib 中移除,编译debug版的程序时,提示连接错误,缺少libboost_date_time-vc120-mt-gd-1_56.lib。

    (2)启用#define BOOST_DATE_TIME_SOURCE 宏,编译debug版的程序时,可发现即使在缺少 libboost_date_time-vc120-mt-gd-1_56.lib的情况下,也能成功编译。

    References

    【1】Boost下载安装编译配置使用指南(含Windows、Linux以及ARM Linux)(http://www.cnblogs.com/wondering/archive/2009/05/21/boost_setup.html

    【2】link 和 runtime-link,搭配shared 和 static(http://blog.csdn.net/yasi_xi/article/details/8660549

    【3】计时函数(二)(http://www.cnblogs.com/jerry19880126/archive/2013/02/20/2919718.html

    【4】官方文档Getting Started on Windows(http://www.boost.org/doc/libs/1_56_0/more/getting_started/windows.html)

    【5】bjam使用(http://blog.chinaunix.net/uid-22301538-id-3158997.html

    编译64位boost

    1. x64环境下编译得先从开始菜单启动Visual Studio的Visual Studio 2010 x64 Win64 Command Prompt进入命令提示符(也能用于build VS2010、VS2015的boost库。x64兼容(Visual Studio 2010 x64 cross Command Prompt)可以在32位系统上编译出在64位系统上运行的程序,而x64(Visual Studio 2010 x64 Win64 Command Prompt)本机是指在64位系统上编译出在64位系统上运行的程序。也就是说x64兼容在一般情况下使用都没有错,不管你的系统是32位还是64位。),而不是随便打开任意一个命令行窗口就行。

    2. 然后转到boost根文件夹,运行bootstrap.bat生成x64版的b2。

    3. 然后运行命令:  

    在boost_1_66_0中

      b2 stage --build-type=complete --stagedir=".lib" --toolset=msvc-10.0  这个用于VS2010 

      b2 stage --build-type=complete --stagedir=".lib" --toolset=msvc-14.0  这个用于VS2015 强烈推荐!                                  所有版本的库文件,都会生成在.lib下,都不冲突

     如果编译过程中,出现boostmovedetail ype_traits.hpp中decltype不认识的,在项目的预定义中加入BOOST_NO_CXX11_DECLTYPE (我在VS2010上的x64位上成功了) 参见:configcompilervisualc.hpp 或 linux上参见configcompilergcc.hpp

    在boost_1_48_0中(发现只能生成32位的)

      b2 stage --build-type=complete --stagedir="." --toolset=msvc-10.0 --address-model=64  这个用于VS2010 强烈推荐!   所有版本的库文件,都会生成在.lib下,都不冲突

      把bin.v2删除   没有这,则下面这还是直接拷贝上一步的内容

      b2 stage --build-type=complete --stagedir="." --toolset=msvc-10.0 --address-model=32  这个用于VS2010 强烈推荐!   所有版本的库文件,都会生成在.lib下,都不冲突

      b2 stage --build-type=complete --stagedir="." --toolset=msvc-14.0 --address-model=64 这个用于VS2015

      把bin.v2删除   没有这,则下面这还是直接拷贝上一步的内容

      b2 stage --build-type=complete --stagedir="." --toolset=msvc-14.0 --address-model=32 这个用于VS2015

    4. 然后拷贝头文件目录D:oost_1_66_0oost到目的地目录的header下,当然也可以放在原地(即不用执行这不)

    这里以 filesystem库为例,如下是它在暂存文件里的层次结构:

    /debug 
    boost_filesystem-mgw45-d-1_40.lib 
    boost_filesystem-mgw45-d-1_40.dll

    /debug/link-static 
    libboost_filesystem-mgw45-d-1_40.lib

    /debug/link-static/runtime-link-static 
    libboost_filesystem-mgw45-sd-1_40.lib

    /debug/link-static/runtime-link-static/threading-multi 
    libboost_filesystem-mgw45-mt-sd-1_40.lib

    /debug/link-static/threading-multi 
    libboost_filesystem-mgw45-mt-d-1_40.lib

    /debug/threading-multi 
    boost_filesystem-mgw45-mt-d-1_40.lib 
    boost_filesystem-mgw45-mt-d-1_40.dll

    /release 
    boost_filesystem-mgw45-1_40.dll 
    boost_filesystem-mgw45-1_40.lib

    /release/link-static 
    libboost_filesystem-mgw45-1_40.lib

    /release/link-static/runtime-link-static 
    libboost_filesystem-mgw45-s-1_40.lib

    /release/link-static/runtime-link-static/threading-multi 
    libboost_filesystem-mgw45-mt-s-1_40.lib

    /release/link-static/threading-multi 
    libboost_filesystem-mgw45-mt-1_40.lib

    /release/threading-multi 
    boost_filesystem-mgw45-mt-1_40.dll 
    boost_filesystem-mgw45-mt-1_40.lib

    由以上的文件夹层次结构基本就可以得出结论:

    1、以“lib”开头的是“link-static”版本的,而直接以“boost”开头的是“link-shared”版本的。

    2、有“d”的为debug版本,没有的则是release版本。

    3、有“s”的为“runtime-link-static”版本(使用静态CRT),没有的则是“runtime-link-shared”版本(使用动态CRT)。

    4、有“mt”的为“threading-multi”版本,没有的则是“threading-single”版本。

    (1)以“lib”开头的是“link=static”版本(静态链接库版本,没有dll),而直接以“boost”开头的是“link=shared”版本(动态链接库版本,包含lib和dll)。

    (2)所有的库都含有"boost"前缀。

    (3)紧随其后的是boost库名称(比如date_time库)。

    (4)然后是编译器的版本,与库名称之间以"-"而不是下划线"_"分隔(比如 -vc120)。

    (5)有“mt”的为“threading=multi”版本,没有的则是“threading=single”版本。

    (6)有“s”的为“runtime-link=static”版本,没有的则是“runtime-link=shared”版本。

    (7)有“gd”的为debug版本,没有的则是release版本。

    (8)所有的库都含有boost库的版本号结尾(比如1_56,其中的"."以下划线"_"代替)

    Windows 7(64位)下通过vs2010完整安装boost 1.46.1(32位/64位)  

    来源:http://china.ygw.blog.163.com/blog/static/68719746201152485054104/

      最新的boost库已经发布了1.46.1版本,但是我接触的比较晚,去年才开始接触并使用,第一次使用的是1.43版本,而且当时安装的时候没有进行完全安装(未包含mpi及python,只涉及32位版本)。这几天重新研究了一下完整安装问题,以下针对Windows 7系统(64位)下通过vs2010完整安装boost 1.46.1(32位/64位)进行详细描述。

            完整安装boost,需要涉及几个第三方库

            1)Regex所需要的Unicode支持类库---ICU。由于自己是使用C/C++,所以需要icu4c。

            2)MPI所需要的类库---Boost的官方站点说需要MPICH或OpenMPI之类的支持,事实上在Windows下总是会提示需要MPIC++,你需要的是Microsoft Cluster Pack SDK,下载并默认安装在C:ProgramFilesMicrosoft Compute Cluster Pack下。(说明:如果安装Microsoft HPC Pack 2008 SDK或Microsoft Compute Cluster Pack时不是装到默认的路径下,那bjam就会找不到mpic++的路径,这时候可以修改一下mpi.jam(在boost_1_46_1 oolsuildv2 ools目录中): local cluster_pack_path_native = "你的路径")。

            3)Python所需要的Python语言库---Python

        但是需要注意,如果选择编译python的话,是需要python语言支持的,应该到python官方主页http://www.python.org/下载安装(所以一般也without)。如果要生成Boost.Python库,需要先下载安装x64版的Python安装包,我用的版本是3.2.3。在使用这个库编写Python扩展DLL时,默认是使用动态库版的Boost.Python,要使用静态版的必须在C++项目中定义BOOST_PYTHON_STATIC_LIB宏,这样就不用在使用或发布扩展时带着boost_python-vc90-mt-1_50.dll一起了,当然扩展DLL的尺寸会大些,如果做实验没必要这样,编译又慢生成的文件也大。

            以下先分步描述相关第三库的安装过程:

            1)ICU4C

                 a)当前icu4c最高版本为4.8,下载的源代码包为icu4c-4_8-src.tgz(个人偏向于通过源代码编译生成,这样会更灵活,比如有问题时可以调试);

                 b)解压icu4c-4_8-src.tgz文件,进入icusourceallinone子目录,用vs2010打开allinone.sln解决方案;

                 c)分别按照Win32(32位程序)/x64(64位程序)下的Debug/Release模式进行编译,其Win32的Debug/Release库文件保存于iculib目录,x64的Debug/Release库文件保存于iculib64目录。需要注意的是:生成相应的Debug/Release库文件后,需要将相应的lib/lib64目录下.dll及.lib文件备份出来,避免编译下一Release/Debug版本时被覆盖;

                 d)将编译后的Win32/x64的Debug/Release文件(.lib及.dll文件)依次保存好(比如x86/x64目录下的debug/release子目录),并在x86/x64目录下的debug/release子目录下新建include目录,并将icu4c的头文件依次拷贝一份到对应的include目录中(后面编译boost时需要)。

            2)MPI

                  最最简单的方式,直接进入前述地址下载安装即可。

            3)Python

                 当前Python最高版本为3.2,从3.2版本开始有了Windows的安装包(安装后直接有了相应的头文件、库文件等,无需经由代码编译)。在这里要说声抱歉,直接经由代码编译有很多问题,总是编译不过,所以暂时使用安装包,待后面代码编译通过后再使用代码包。(注意,编译32位boost程序时安装32位的python,编译完成后再卸载,然后再安装64位的python,继续进行64位boost的编译,反之亦然)

            至此,安装boost所需要的相关第三方库已经准备完成,现在正式开始boost 1.46.1的安装过程:

            1)通过boost网站下载最新的boost源代码包boost_1_46_1.tar.gz并解压;

            2)用UltraEdit打开boost_1_46_1oost_1_46_1 oolsuildv2目录下的user-config.jam文件,并在最后增加两行“using mpi ;”(注意,mpi与;之间有一个空格)、“using python : 3.2 : c:\python32 ;”(注意,3.2与;之间有一个空格,另外,3.2为python的版本号(只需要主版本号与次版本号),c:\python32为python的安装目录,windows下需要将路径的符号转换为\)

            3)通过vs2010的“Visual Studio Command Prompt (2010)”(编译32位)、“Visual Studio X64 Win64 Command Prompt (2010)”(编译64位)菜单项进入vs2010命令行,并进入解压后的boost_1_46_1oost_1_46_1目录;

            4)执行bootstrap.bat命令(只需要执行一次即可);

            5)x86/x64下的debug/release编译命令分别是:

                 a)x86 debug                   

    bjam install --prefix=e:uildoost1.46.1x86debug toolset=msvc-10.0 variant=debug link=shared address-model=32 threading=multi runtime-link=shared -s ICU_PATH=E:uildicu4c4.8x86debug

                 b)x86 release                    

    bjam install --prefix=e:uildoost1.46.1x86 elease toolset=msvc-10.0 variant=release link=shared address-model=32 threading=multi runtime-link=shared -sICU_PATH=E:uildicu4c4.8x86 elease

                 c)x64 debug                     

    bjam install --prefix=e:uildoost1.46.1x64debug toolset=msvc-10.0 variant=debug link=shared address-model=64 threading=multi runtime-link=shared -sICU_PATH=E:uildicu4c4.8x64debug

                 d)x64 release                    

    bjam install --prefix=e:uildoost1.46.1x64 elease toolset=msvc-10.0 variant=release link=shared address-model=64 threading=multi runtime-link=shared -sICU_PATH=E:uildicu4c4.8x64 elease

       6)其中,--prefix设置boost安装目录;stage表示只生成库文件(dll与lib文件);toolset指定编译器,vs2010就是msvc-10.0,vs2005/vs2008分别是msvc-8.0与msvc-9.0;variant决定编译什么版本;link决定使用静态库还是动态库,shared是动态库,static是静态库;address-model决定地址长度,即32还是64位程序;threading决定使用单线程(single)还是多线程(multi)库;runtime-link决定是静态(static)还是动态(shared)链接C/C++标准库;-s ICU_PATH设置icu4c的路径;install会生成包含头文件的include目录。

            至此,windows 7(64位)系统下使用vs2010完全编译boost 1.46.1完成(含x86/x64的debug与release版本)。

    Version 1.72.0

    1. Open Visual Studio 2015 Tools Command Prompt
    2. bootstrap.bat vc14 会产生b2.exe文件
    3. E:oost_1_72_0>.2 --help    查看一下用法

    Boost.Build 4.0-git

    Project-specific help:

    Project has jamfile at Jamroot

    Usage:

    b2 [options] [properties] [install|stage]

    Builds and installs Boost.

    Targets and Related Options:

    install           Install headers and compiled library files to the          我们一般不用这种,感觉会用于linux中(除了要build出来的东西,还要拷贝其它头文件等)  下面的选项,只能用于install
    =======            configured locations (below).

    --prefix=<PREFIX>       Install architecture independent files here.
                   Default: C:Boost on Windows
                   Default: /usr/local on Unix, Linux, etc.

    --exec-prefix=<EPREFIX>   Install architecture dependent files here.
                  Default: <PREFIX>

    --libdir=<LIBDIR>        Install library files here.
                  Default: <EPREFIX>/lib

    --includedir=<HDRDIR>    Install header files here.
                  Default: <PREFIX>/include

    --cmakedir=<CMAKEDIR>    Install CMake configuration files here.
                  Default: <LIBDIR>/cmake

    --no-cmake-config        Do not install CMake configuration files.

    stage            Build and install only compiled library files to the  我们一般用这种(只要build出来的东西就行(其它东西都有了))     下面的选项,只能用于stage
    =====           stage directory.

    --stagedir=<STAGEDIR>    Install library files here
                  Default: ./stage                      在Windows上如果是--stagedir="./lib" 表示在./lib/lib/       --stagedir="./" 表示在./lib/     --stagedir="."会出现拷贝错误,然后./lib/下啥都没有

    Other Options:

    --build-type=<type> Build the specified pre-defined set of variations of
    the libraries. Note, that which variants get built
    depends on what each library supports.

    -- minimal -- (default) Builds a minimal set of
    variants. On Windows, these are static
    multithreaded libraries in debug and release
    modes, using shared runtime. On Linux, these are
    static and shared multithreaded libraries in
    release mode.

    -- complete -- Build all possible variations.

    --build-dir=DIR Build in this location instead of building within
    the distribution tree. Recommended!

    --show-libraries Display the list of Boost libraries that require
    build and installation steps, and then exit.

    --layout=<layout> Determine whether to choose library names and header
    locations such that multiple versions of Boost or
    multiple compilers can be used on the same system.

    -- versioned -- Names of boost binaries include
    the Boost version number, name and version of
    the compiler and encoded build properties. Boost
    headers are installed in a subdirectory of
    <HDRDIR> whose name contains the Boost version
    number.

    -- tagged -- Names of boost binaries include the
    encoded build properties such as variant and
    threading, but do not including compiler name
    and version, or Boost version. This option is
    useful if you build several variants of Boost,
    using the same compiler.

    -- system -- Binaries names do not include the
    Boost version number or the name and version
    number of the compiler. Boost headers are
    installed directly into <HDRDIR>. This option is
    intended for system integrators building
    distribution packages.

    The default value is 'versioned' on Windows, and
    'system' on Unix.

    --buildid=ID Add the specified ID to the name of built libraries.
    The default is to not add anything.

    --python-buildid=ID Add the specified ID to the name of built libraries
    that depend on Python. The default is to not add
    anything. This ID is added in addition to --buildid.

    --help This message.

    --with-<library> Build and install the specified <library>. If this
    option is used, only libraries specified using this
    option will be built.

    --without-<library> Do not build, stage, or install the specified
    <library>. By default, all libraries are built.

    Properties:

    toolset=toolset Indicate the toolset to build with.    可以不指定,通过使用特定的 Tools Command Prompt(例如Open Visual Studio 2015 Tools Command Prompt),来默认选中那种toolset

    variant=debug|release Select the build variant

    link=static|shared Whether to build static or shared libraries

    threading=single|multi Whether to build single or multithreaded binaries

    runtime-link=static|shared
    Whether to link to static or shared C and C++
    runtime.


    General command line usage:

    b2 [options] [properties] [targets]

    Options, properties and targets can be specified in any order.

    Important Options:

    * --clean Remove targets instead of building
    * -a Rebuild everything
    * -n Don't execute the commands, only print them
    * -d+2 Show commands as they are executed
    * -d0 Suppress all informational messages
    * -q Stop at first error
    * --reconfigure Rerun all configuration checks
    * --debug-configuration Diagnose configuration
    * --debug-building Report which targets are built with what properties
    * --debug-generator Diagnose generator search/execution

    Further Help:

    The following options can be used to obtain additional documentation.

    * --help-options Print more obscure command line options.
    * --help-internal Boost.Build implementation details.
    * --help-doc-options Implementation details doc formatting.

    ...found 1 target...

      4.E:oost_1_72_0>.2 stage --build-type=complete                                          会在.stagelib下面产生x32和x64的所有版本lib和dll                       不推荐

                .2 stage --build-type=complete --stagedir="./"           除非需要指定非默认的toolset,则需要使用--toolset选项,例如 --toolset=msvc-10.0            推荐  

     在build出的东西命名上:

    注意这边用的是VC的版本,而不是指VS的版本(这个通过VS的About中查看到)
    v142 表示VS2019
    v141 表示VS2017中的MSVC V141
    v140 表示VS2015
    v100 表示VS2010
    v90 表示VS2008

     

  • 相关阅读:
    使用element-ui是下拉筛选选择
    vue 组件传值
    vue element 地址联动的使用
    vux scroller
    实时监听组件中路由的变化
    vuex的使用
    对移动端滚动高度的获取
    【转】ACM 取石子问题
    【转】ACM博弈知识汇总
    EOJ 2857 编辑距离
  • 原文地址:https://www.cnblogs.com/spriteflk/p/4864127.html
Copyright © 2011-2022 走看看