boost库生成文件命名和编译(转载)

Boost库编译与文件命名规则详解
本文详细介绍了Boost库的文件命名规则,包括BOOST_LIB_PREFIX、BOOST_LIB_NAME、BOOST_LIB_TOOLSET等组成部分,以及如何使用bjam工具进行编译。编译选项如variant、link、threading等影响生成的静态库或动态库类型。同时,文章讨论了Boost库文件命名与C运行时库链接方式的关系,并提供了不同编译选项下的文件命名示例。

boost库生成文件命名和编译

(原址:http://www.cppblog.com/Robertxiao/archive/2013/01/06/197022.html)

生成文件命名规则:boost中有许多库,有的库需要编译、而有的库不需要编译,只需包含头文件就可以使用。编译生成的文件名字普遍较长,同一个库根据编译链接选项不同,又可以生成多个不同名字的文件。生成的文件名字是很长,可是这样带的信息才多,也就容易识别出用途。其实生成文件的名字遵循一定的规则,有着固定的格式。识别这种格式,能帮助我们更高效地使用boost库。生成文件名字格式如: 

   BOOST_LIB_PREFIX + BOOST_LIB_NAME + "-" + BOOST_LIB_TOOLSET + "-" + BOOST_LIB_THREAD_OPT + "-" + BOOST_LIB_RT_OPT + "-" + BOOST_LIB_VERSION  

   这些定义为:

  BOOST_LIB_PREFIX: 静态库为 "lib" (否则无,是用动态链接库)

  BOOST_LIB_NAME: 库的基本名称 ( 比方说 boost_regex).

  BOOST_LIB_TOOLSET: 编译工具集名称 ( 比如:vc6, vc7, bcb5 )

  BOOST_LIB_THREAD_OPT: 多线程为 "-mt" ,否则为空

  BOOST_LIB_RT_OPT: 指示使用的运行库的后缀, 

   组合下面的一个或者更多字符:

   s 静态运行库,指的是静态链接到运行时库(不出现表示动态).

   g 调试/诊断 runtime (release if not present).

   d 调试版本 (不出现表示 release 版 ).

   p STLPort 版本.

   注:对 vc 来说,gd 总是一起出现

  BOOST_LIB_VERSION: Boost 版本, Boost 版本 x.y 表示为 x_y形式.
 
 编译:为了简化boost库的编译,boost库中带了一个用来编译的工具,名字是bjam.exe或者b2.exe.

1:运行boost下的bootstap.bat脚本就会自动生上述的两个编译工具,并且拷贝到boost目录下. 也可以进入tools/build目录下找到类似的脚本或者项目源码来编译.

2: bjam.exe的参数

Feature

Allowed values

Notes

variant

debug,release

link

shared,static

Determines if Boost.Build creates shared or static libraries

threading

single,multi

Cause the produced binaries to be thread-safe. This requires proper support in the source code itself.

address-model

32,64

Explicitly request either 32-bit or 64-bit code generation. This typically requires that your compiler is appropriately configured. Please refer to the section called “C++ Compilers” and your compiler documentation in case of problems.

toolset

(Depends on configuration)

The C++ compiler to use. See the section called “C++ Compilers” for a detailed list.

(Vs2008)msvc-8.0 (vs2010)msvc-10.0

include

(Arbitrary string)

Additional include paths for C and C++ compilers.

define

(Arbitrary string)

Additional macro definitions for C and C++ compilers. The string should be either SYMBOL or SYMBOL=VALUE

cxxflags

(Arbitrary string)

Custom options to pass to the C++ compiler.

cflags

(Arbitrary string)

Custom options to pass to the C compiler.

linkflags

(Arbitrary string)

Custom options to pass to the C++ linker.

runtime-link

shared,static

Determines if shared or static version of C and C++ runtimes should be used.

--build-dir=<builddir>

编译的临时文件会放在builddir里(这样比较好管理,编译完就可以把它删除了)

--stagedir=<stagedir>

存放编译后库文件的路径,默认是stage

--build-type=complete

编译所有版本,不然只会编译一小部分版本(确切地说是相当于:variant=release, threading=multi;link=shared|static;runtime-link=shared)

variant=debug|release

决定编译什么版本(对应文件中的d 调试版本 不出现表示 release 版)

link=static|shared

决定使用静态库还是动态库。(对应文件中的BOOST_LIB_PREFIX )

threading=single|multi

决定使用单线程还是多线程库。(对应文件中的BOOST_LIB_THREAD_OPT)

runtime-link=static|shared

决定是静态还是动态链接C/C++标准库。(对应文件中的BOOST_LIB_THREAD_OPT)

--with-<library>

只编译指定的库,如输入--with-regex就只编译regex库了。

--show-libraries

显示需要编译的库名称

bjam.exe --toolset=msvc-10.0 --with-date_time runtimelink=static link=static stage 
意思是要生静态库,该静态库静态链接C运行时库
生成的文件名字是:libboost_date_time-vc100-mt-sgd-1_48.lib(debug version),libboost_date_time-vc100-mt-s-1_48.lib(release version) 两个文件.

bjam.exe --toolset=msvc-10.0 --with-date_time runtimelink=shared link=static stage
意思是要生静态库,该静态库动态链接C运行时库
生成的文件名字是:libboost_date_time-vc100-mt-gd-1_48.lib(debug verion),libboost_date_time-vc100-mt-1_48.lib(release version) 两个文件.

bjam.exe --toolset=msvc-10.0 --with-date_time runtimelink=shared link=shared stage
意思是要生动态库,该动态库动态链接C运行时库
生成的文件名字是:boost_date_time-vc100-mt-gd-1_48.lib(debug version),boost_date_time-vc100-mt-1_48.lib(release version) 两个文件.
生成的dll名字是:boost_date_time-vc100-mt-gd-1_48.dll(debug version),boost_date_time-vc100-mt-1_48.dll(release version)

编译选项方面还有install等参数.

Boost库编译后命名方式

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标记:编码了影响库和其他编译代码交互的细节。对于每一种特性,向标记中添加一个字母: 
    KeyUse 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

修复操作流程1 Welcome to AidLux! Work with AidLux packages using tool ‘aid-pkg’: Update list of available packages: aid-pkg update List packages: aid-pkg list Install packages: aid-pkg install <package-name> Remove packages: aid-pkg remove <package-name> Search packages: aid-pkg search <pattern> Install AidLux Web Desktop using command: aid-pkg install aid-desktop aidlux@localhost:~$ sudo dpkg --configure -a # 强制完成未完成的安装配置 Setting up docbook-xml (4.5-9) … Setting up libfprint-2-2:arm64 (1:1.90.2+tod1-0ubuntu1~20.04.10) … Failed to scan devices: Permission denied dpkg: error processing package libfprint-2-2:arm64 (–configure): installed libfprint-2-2:arm64 package post-installation script subprocess returned error exit status 1 dpkg: dependency problems prevent configuration of fprintd: fprintd depends on libfprint-2-2 (>= 1:1.90.1); however: Package libfprint-2-2:arm64 is not configured yet. dpkg: error processing package fprintd (–configure): dependency problems - leaving unconfigured dpkg: dependency problems prevent configuration of libpam-fprintd:arm64: libpam-fprintd:arm64 depends on fprintd (= 1.90.9-1~ubuntu20.04.1); however: Package fprintd is not configured yet. dpkg: error processing package libpam-fprintd:arm64 (–configure): dependency problems - leaving unconfigured Processing triggers for rygel (0.38.3-1ubuntu1) … Processing triggers for libgdk-pixbuf2.0-0:arm64 (2.40.0+dfsg-3ubuntu0.5) … Processing triggers for dbus (1.12.16-2ubuntu2.3) … Processing triggers for sgml-base (1.29.1) … Processing triggers for dictionaries-common (1.28.1) … debconf: unable to initialize frontend: Dialog debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 76.) debconf: falling back to frontend: Readline aspell-autobuildhash: processing: en [en-common]. aspell-autobuildhash: processing: en [en-variant_0]. aspell-autobuildhash: processing: en [en-variant_1]. aspell-autobuildhash: processing: en [en-variant_2]. aspell-autobuildhash: processing: en [en-w_accents-only]. aspell-autobuildhash: processing: en [en-wo_accents-only]. aspell-autobuildhash: processing: en [en_AU-variant_0]. aspell-autobuildhash: processing: en [en_AU-variant_1]. aspell-autobuildhash: processing: en [en_AU-w_accents-only]. aspell-autobuildhash: processing: en [en_AU-wo_accents-only]. aspell-autobuildhash: processing: en [en_CA-variant_0]. aspell-autobuildhash: processing: en [en_CA-variant_1]. aspell-autobuildhash: processing: en [en_CA-w_accents-only]. aspell-autobuildhash: processing: en [en_CA-wo_accents-only]. aspell-autobuildhash: processing: en [en_GB-ise-w_accents-only]. aspell-autobuildhash: processing: en [en_GB-ise-wo_accents-only]. aspell-autobuildhash: processing: en [en_GB-ize-w_accents-only]. aspell-autobuildhash: processing: en [en_GB-ize-wo_accents-only]. aspell-autobuildhash: processing: en [en_GB-variant_0]. aspell-autobuildhash: processing: en [en_GB-variant_1]. aspell-autobuildhash: processing: en [en_US-w_accents-only]. aspell-autobuildhash: processing: en [en_US-wo_accents-only]. Processing triggers for libc-bin (2.31-0ubuntu9.2) … Errors were encountered while processing: libfprint-2-2:arm64 fprintd libpam-fprintd:arm64 aidlux@localhost:~ParseError: KaTeX parse error: Expected 'EOF', got '#' at position 39: …lock-frontend #̲ 清除锁定文件 aidlux@… sudo rm /var/lib/dpkg/lock sudo rm /va
04-01
<think>嗯,用户遇到了在安装AidLux Web Desktop时出现的依赖配置错误,特别是与libfprint-2-2:arm64相关的权限问题。首先,我需要理解错误信息。日志显示在配置libfprint-2-2时,扫描设备失败,权限被拒绝。这可能是因为某些服务需要更高的权限或某些文件被锁定。 接下来,用户尝试了强制完成安装配置的命令sudo dpkg --configure -a,但依然失败。然后用户开始手动删除锁文件,但命令被截断了。这说明用户可能没有正确清除所有的锁文件,或者还有其他依赖问题未解决。 我需要考虑可能的解决方案。首先,应该检查是否有未完成的安装进程占用了dpkg,导致锁文件存在。这时候需要确保所有包管理进程都停止,并清除锁文件。用户可能只删除了/var/lib/dpkg/lock,但可能还有/var/lib/apt/lists/lock/var/cache/apt/archives/lock需要处理。 然后,处理依赖问题。因为错误提到libfprint-2-2配置失败,可能需要手动修复。使用sudo apt install -f来修复依赖,或者尝试重新安装有问题的包。如果这些步骤无效,可能需要完全清除并重新安装相关包,比如fprintdlibfprint。 另外,权限问题也可能导致设备扫描失败。可能需要检查相关服务(如fprintd)的权限,或者暂时禁用指纹识别功能,特别是如果用户不需要它的话。通过卸载相关的包,可以避免依赖冲突,继续安装AidLux。 最后,确保用户正确执行了安装AidLux Web Desktop的步骤,即运行aid-pkg install aid-desktop,并在必要时重启服务或系统。如果所有方法都失败,建议用户查阅AidLux的官方文档或联系支持,因为可能涉及特定于该平台的问题。 需要将这些步骤清晰地传达给用户,确保他们逐步操作,避免遗漏关键步骤,比如清除所有锁文件或正确配置依赖。同时,注意用户可能对Linux系统不太熟悉,所以解释要简明,避免技术术语过多,必要时给出具体的命令示例。</think>在安装AidLux Web Desktop时出现的依赖配置错误,可通过以下步骤排查修复: --- ### **错误分析** 从日志看出主要问题: 1. `libfprint-2-2:arm64` 包配置失败(指纹识别权限问题) 2. `fprintd` `libpam-fprintd:arm64` 因依赖关系未配置 3. 系统存在未完成的安装进程(锁定文件残留) --- ### **修复流程** #### **步骤1:清除锁定文件** ```bash sudo rm /var/lib/dpkg/lock # 删除dpkg进程锁 sudo rm /var/lib/apt/lists/lock # 删除apt资源列表锁 sudo rm /var/cache/apt/archives/lock # 删除apt缓存锁 ``` #### **步骤2:强制修复依赖关系** ```bash sudo dpkg --configure -a # 继续未完成的配置 sudo apt install -f # 修复依赖链断裂问题 ``` #### **步骤3:手动处理问题包** - **尝试重新配置包**: ```bash sudo dpkg-reconfigure libfprint-2-2:arm64 ``` - **若仍失败,强制移除问题包**: ```bash sudo dpkg --remove --force-remove-reinstreq libfprint-2-2:arm64 sudo apt autoremove # 清理残留依赖 ``` #### **步骤4:安装必要组件** 若系统无需指纹识别功能,可跳过相关包: ```bash sudo apt-mark hold libfprint-2-2:arm64 # 禁止自动安装该包 sudo apt install aid-desktop # 重新尝试安装AidLux桌面 ``` --- ### **关键问题说明** 1. **权限问题**:`libfprint-2-2` 需要访问硬件设备,确保: ```bash sudo chmod 666 /dev/usb/hiddev* # 临时赋予设备节点读写权限 ``` 2. **依赖冲突**:若步骤3无效,尝试完全卸载指纹相关组件: ```bash sudo apt purge fprintd libpam-fprintd ``` --- ### **最终验证** ```bash sudo apt update && sudo apt upgrade # 更新系统 aid-pkg install aid-desktop # 重新安装AidLux桌面 ``` 若仍报错,建议检查AidLux官方文档或联系支持,因可能与特定硬件/内核模块兼容性相关。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值