bjam 编译boost

bjam 编译boost

 

link=static variant=debug,release threading=multi runtime-link=static --layout=versioned --toolset=msvc-9.0  --build-type=complete  stage
--build-dir=<builddir>  编译的临时文件会放在builddir里(这样比较好管理,编译完就可以把它删除了)
--stagedir=<stagedir>  存放编译后库文件的路径,默认是stage
--build-type=complete  编译所有版本,不然只会编译一小部分版本(确切地说是相当于:variant=release, threading=multi;link=shared|static;runtime-link=shared)
variant=debug|release  决定编译什么版本(Debug or Release?)
link=static|shared  决定使用静态库还是动态库。
threading=single|multi  决定使用单线程还是多线程库。
runtime-link=static|shared  决定是静态还是动态链接C/C++标准库。
--with-<library>  只编译指定的库,如输入--with-regex就只编译regex库了。
--show-libraries  显示需要编译的库名称

boost库的命名约定:
[lib]<boost模块名>-<toolset编译器>[-mt][-sgdyp]<-boost版本>.<扩展名>
    [lib]:所有模块均采用lib为前缀,除了windows+msvc环境。在windows+msvc环境下,只有静态库(.lib)才有lib前缀,动态库(.dll)没有lib前缀。windows+mingw环境也使用lib前缀。
    <boost模块名>:所有模块均以boost_开头,比如boost_date_time, boost_python等等
    <toolset编译器>:比如mgw45, vc90
    [-mt]:多线程支持,不指定则默认为仅支持单线程
    [-sgdyp]:ABI的详细情况
        s 静态链接到C++标准库和运行库
        g 使用debug版的标准库和运行库
        d 编译debug版
        y python相关的debug
        p 使用STLPort作为C++标准库而不是编译器默认提供的
    <-boost版本>:比如-1_45
    <扩展名>:
        windows+mingw:dll(动态库),dll.a(动态库的导入库)
        windows+msvc:dll(动态库),lib(无lib前缀的是动态库的导入库),lib(有lib前缀的是静态库)
        unix/linux:a(静态库),so(动态库)
        使用boost
    windows+msvc编译出来的boost库默认会打开auto-link功能,即在包含boost头文件的时候自动寻找并链接依赖库。这实际上是通过msvc特有的预处理指令#pragma comment(lib, "xxx.lib")来实现的,默认的实现为链接静态库。
        如果想要链接动态库,则需要使用预定义宏 -DBOOST_ALL_DYN_LINK
        如果想要完全手动控制链接方式,则需要使用预定义宏 -DBOOST_ALL_NO_LIB。
    windows+mingw编译出来的boost库不支持auto-link,因为gcc没有类似msvc的#pragma comment预处理指令,所以必须手动控制链接方式。
    asio:依赖Boost.system模块,并且如果用到特定功能还可能依赖Boost.regex, Boost.openssl, Boost.thread, Boost.date_time, Boost.serialization等等,可以使用预定义宏 -DBOOST_DATE_TIME_NO_LIB 以及 -DBOOST_REGEX_NO_LIB 关闭相应模块的自动链接。windows下asio最终使用的是windows系统的socket库:ws2_32.lib,Mswsock.lib.同理,msvc可以通过auto-link自动完成链接,mingw需要手动设置。
    使用msvc编译真是有些玄妙:
使用预定义宏BOOST_ALL_DYN_LINK,动态链接:则编译时需要动态链接库导入库system,date_time,regex,执行时需要system,date_time。
使用预定义宏BOOST_ALL_NO_LIB,动态链接:则编译时需要动态链接库导入库system,执行时也只需要system。
使用预定义宏BOOST_ALL_NO_LIB,静态链接:则编译时需要静态库system,执行时不需要system。
 
使用mingw编译,一切正常:
注意上述几个预定义宏只对msvc有用而对mingw是不起作用的
动态链接:则编译时需要动态链接库导入库system,执行时也只需要system
静态链接:则编译时需要静态库system,执行时不需要system
当然ws2_32, Mswsock总是要指定链接的。
Usage:
Bjam  [options]  [properties]  [install|stage]
 
 
install                 Install  headers and compiled library files to the
=======               configured locations (below).
                      在“--prefix=”指定的目录下生成所有头文件
           (boost源代码下boost文件夹下所有文件)和指定库文件
 
--prefix=<PREFIX>       Install architecture independent files here.
                     Default; C:\Boost on Win32
                     Default; /usr/local on Unix. Linux, etc.
 
--exec-prefix=<EPREFIX>  Install architecture dependent files here.
                     Default; <PREFIX>
 
--libdir=<DIR>          Install library files here.
                     Default; <EPREFIX>/lib
 
--includedir=<HDRDIR>   Install header files here.
                      Default; <PREFIX>/include
 
stage                 Build and install only compiled library files
======               to the stage directory.
                          在“--stagedir=”指定的目录下生成指定库文件
 
 
--stagedir=<STAGEDIR>   Install library files here
                      Default; ./stage
 
 
【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 the single
                     "release" version of the libraries. This
                     release corresponds to specifying:
                     "release  <threading>multi  <link>shared
                     <link>static  <runtime-link>shared" as the
                     Build variant to build.
                     complete - Attempts to build all possible
                     variations.
 
--build-dir=DIR         Build in this location instead of building
                     within the distribution tree. Recommended!
 
--show-libraries        Displays the list of Boost libraries that require
                     build and installation steps, then exit.
 
--layout=<layout>       Determines 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 (default) - Names of boost
                     binaries include the Boost version
                     number and the name and version of the
                     compiler. Boost headers are installed
                     in a subdirectory of <HDRDIR> whose
                     name contains the Boost version number.
 
                     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 who
                     are building distribution packages.
 
--buildid=ID                    Adds the specified ID to the name of built
                        libraries. The default is to not add anything.
 
--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            Indicates the toolset to build with.
                                                        msvc-6.0 :  VC6.0
msvc-7.0:  VS2003
                                                        msvc-8.0:  VS2005
                                                        msvc-9.0:  VS2008
                                                        msvc-10.0:  VS2010
 
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.
                         决定是静态还是动态链接C/C++标准库


compile gce dependence lib

b2 --toolset=msvc-14.0  link=static variant=debug,release threading=multi runtime-link=static  asmflags=\safeseh --stagedir=../.. --with-thread --with-atomic  --with-coroutine --with-context --with-system --with-regex --with-date_time --with-chrono
[context] msvc /SAFESEH

http://comments.gmane.org/gmane.comp.lib.boost.devel/244402

你可能感兴趣的:(bjam 编译boost)