yys

Maya插件开发,(多多练习英文吧~)

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

Boost库编译后命名方式

from http://www.cnblogs.com/dementia/archive/2009/04/10/1433217.html

Boost官网的《Geting Started On Windows》(http://www.boost.org/doc/libs/1_38_0/more/getting_started/windows.html)提到了Boost库的命名,摘录如下:

以 libboost_regex-vc71-mt-d-1_34.lib 为例:

  • lib
    前缀:除了Microsoft Windows之外,每一个Boost库的名字都以此字符串开始。在Windows上,只有普通的静态库使用lib前缀;导入库和DLL不使用。
  • boost_regex
    库名称:所有boost库名文件以boost_开头。
  • -vc71
    Toolset 标记:标识了构建该库所用的toolset和版本。
  • -mt
    Threading 标记:标识构建该库启用了多线程支持。不支持多线程的库没有-mt。
  • -d
    ABI标记:编码了影响库和其他编译代码交互的细节。对于每一种特性,向标记中添加一个字母:
    Key Use this library when:
    s 静态链接到C++标准库和编译器运行时支撑库
    g 使用标准库和运行时支撑库的调试版本
    y 使用Python的特殊调试构建
    d 构建代码的调试版本
    p 使用STLPort标准库而不是编译器提供的默认库
    n 使用STLPort已被弃用的“native iostreams”
  • -1_34
    版本标记:完整的Boost发布号,下划线代替点。例如,1.31.1版本将被标记为“-1_31_1”。
  • .lib
    扩展名:取决于操作系统。在大多数unix平台上,.a是静态库,.so是共享库。在Windows上,.dll表示共享库,.lib是静态或导入库。

下表是对Regex库编译后的文件名:

文件名 含义 编译使用该库的程序时应使用的编译选项
libboost_regex-vc90-mt-sgd-1_38.lib 静态库,多线程,调试版本
使用静态调试版本C运行时库(LIBCMTD.LIB和LIBCPMTD.LIB)
/MTd
libboost_regex-vc90-mt-s-1_38.lib 静态库,多线程
使用静态版本C运行时库(LIBCMT.LIB和LIBCPMT.LIB)
/MT
libboost_regex-vc90-mt-gd-1_38.lib 静态库,多线程,调试版本
使用动态调试版本C运行时库(MSVCRTD.LIB和MSVCPRTD.LIB)
/MDd
libboost_regex-vc90-mt-1_38.lib 静态库,多线程
使用动态版本C运行时库(MSVCRT.LIB和MSVCPRT.LIB)
/MD
boost_regex-vc90-mt-gd-1_38.lib 导入库(boost_regex-vc90-mt-gd-1_38.dll),多线程,调试版本  
boost_regex-vc90-mt-1_38.lib 导入库(boost_regex-vc90-mt-1_38.dll)多线程  

需要注意的是,链接时,所使用的Regex库文件名必须和编译选项匹配,否则会造成如下链接错误:

LINK : warning LNK4098: defaultlib '×××××' conflicts with use of other libs; use /NODEFAULTLIB:library

原因是,当编译时,cl.exe(也就是VC的编译器)会根据上述编译选项在编译成的obj文件中植入相应的defaultlib文件名(使用DUMPBIN /DIRECTIVE***,lib可以查看),如/MT对应的就是LIBCMT.LIB(C)和LIBCPMT.LIB(C++标准库)。当链接器处理该obj文件时,会从文件中取出该defaultlib文件名,将其放在命令行库列表的最后以供使用。对于静态库的处理也是如此,静态库也是由一些obj文件组成的,每个obj文件中也根据当时的编译选项被植入了相应的defaultlib。当链接器处理静态库时,也会将涉及到的obj文件中的defaultlib放在命令行库列表的最后。假设,我们的程序使用/MT编译,那个对应的defaultlib就是LIBCMT.LIB(C)和LIBCPMT.LIB(C++标准库)。而使用的是libboost_regex-vc90-mt-sgd-1_38.lib,它对应的defaultlib就是LIBCMTD.LIB和LIBCPMTD.LIB。链接过程中,链接器会发现采用了不同的运行时库,所以会出现上述错误。

幸运的是,Visual C++支持自动链接,当包含Regex的头文件时,Regex会根据当前工程的编译选项(不同的编译选项会定义不同的宏,具体参见上一篇C运行时库)自动告诉编译器将哪个文件送给链接器。

Boost.Regex默认使用的静态链接方式,如果希望使用动态链接方式,如何实现呢? 定义宏BOOST_REGEX_DYN_LINK。要注意,一定要在包含regex头文件之前定义该宏:

#define  BOOST_REGEX_DYN_LINK
#include 
<boost/regex.hpp>

关于此宏的解释参见 http://www.boost.org/doc/libs/1_38_0/libs/regex/doc/html/boost_regex/configuration/linkage.html

 

   

Build boost-iostreams with zlib

from http://slimemeteor.blogspot.com/2010/09/boost-lib-build-with-zlib-for-iostream.html
and http://tlzprgmr.wordpress.com/2010/03/17/building-boost-1-42-with-zlib-1-2-4-support/

 


【步骤】

建立E:\dev\boost\build,存放build时的中间文件

>cd E:\dev\boost\1_39
E:\dev\boost\1_39>%comspec% /k ""D:\Program Files\Microsoft Visual Studio 8\VC\vcvarsall.bat"" x86
(如果是x64,执行%comspec% /k ""D:\Program Files (x86)\Microsoft Visual Studio 8\VC\vcvarsall.bat"" x64)
E:\dev\boost\1_39>E:\dev\boost\1_39\bjam.exe --build-dir="E:\dev\boost\build" --toolset=msvc-8.0 -sNO_ZLIB=0 -sZLIB_SOURCE="E:\dev\tools\zlib\1.2.5" --with-iostreams --build-type=complete stage


如果遇到boost提示gzio.c文件找不到的错误,(参照这里http://tlzprgmr.wordpress.com/2010/03/17/building-boost-1-42-with-zlib-1-2-4-support/)解决方法如下:
把E:\dev\boost\1_39\libs\iostreams\build\Jamfile.v2里的这一行(搜索gzio,只有一处)
     crc32 deflate gzio infback inffast inflate inftrees trees uncompr zutil :中的gzio删去,即:
crc32 deflate infback inffast inflate inftrees trees uncompr zutil :


再次执行【步骤】里的命令.

build后会在E:\dev\boost\build\boost\bin.v2\libs\iostreams\build下生成:

boost_iostreams-vc80-mt-1_39.lib
boost_iostreams-vc80-mt-gd-1_39.lib
boost_zlib-vc80-mt-1_39.lib
boost_zlib-vc80-mt-gd-1_39.lib
libboost_iostreams-vc80-mt-1_39.lib
libboost_iostreams-vc80-mt-gd-1_39.lib
libboost_iostreams-vc80-mt-s-1_39.lib
libboost_iostreams-vc80-mt-sgd-1_39.lib
libboost_iostreams-vc80-s-1_39.lib
libboost_iostreams-vc80-sgd-1_39.lib
libboost_zlib-vc80-mt-1_39.lib
libboost_zlib-vc80-mt-gd-1_39.lib
libboost_zlib-vc80-mt-s-1_39.lib
libboost_zlib-vc80-mt-sgd-1_39.lib
libboost_zlib-vc80-s-1_39.lib
libboost_zlib-vc80-sgd-1_39.lib

同时这些文件会拷贝到 E:\dev\boost\1_39\stage\lib

(END)



How to get Boost libraries binaries that work with Visual Studio?

(http://stackoverflow.com/questions/2049952/how-to-get-boost-libraries-binaries-that-work-with-visual-studio)

There are three different options for accessing the binary libraries:

1) Build them from source.
Go into the boost directory and run:

    bootstrap
    .\bjam

Or get more complicate and do something like:

    bjam --stagedir="c:\Program Files\Boost"--build-type=complete --toolset=msvc-9.0--with-regex --with-date_time --with-thread --with-signals --with-system --with-filesystem --with-program_options stage

2) Use the BoostPro installer (http://www.boostpro.com/download) to get the specific libraries that you need.
This is very nice because it only downloads and installs the files that you say you want. However, it never has the most current version available, and there are no 64 bit binaries.

3) Download the entire set of libraries (http://boost.teeks99.com)
Easy to use, simple to do, but the libraries are huge (7GB unzipped!).
Edit 2013-05-13: My builds are now available (starting from 1.53) directly from the sourceforge page.






posted on 2010-10-29 19:32  yys  阅读(3847)  评论(1编辑  收藏  举报