如何使用 'clang-win' 工具集构建调试增强静态库?

How to build debug boost static libraries with 'clang-win' toolset?

我在使用 clang-win 工具集构建标准和运行时支持库的调试版本时遇到问题(使用 msvc 工具集一切正常)

具体来说,我正在尝试构建 lib 文件的 mt-gd 变体,因此我将 runtime-debugging=on 开关添加为 Boost docs 说但无济于事
这是我得到的:

1) b2 toolset=msvc-14.1 address-model=64 --with-filesystem variant=release
生成 libboost_filesystem-vc141-mt-x64-1_72.lib [正确]

2) b2 toolset=msvc-14.1 address-model=64 --with-filesystem runtime-debugging=on variant=debug
生成 libboost_filesystem-vc141-mt-gd-x64-1_72.lib [正确]

3) b2 toolset=clang-win address-model=64 --with-filesystem variant=release
生成 libboost_filesystem-clangw9-mt-x64-1_72.lib [正确]

4) b2 toolset=clang-win address-model=64 --with-filesystem runtime-debugging=on variant=debug
生成 libboost_filesystem-clangw9-mt-d-x64-1_72.lib [不正确]
应该是 libboost_filesystem-clangw9-mt-gd-x64-1_72.lib

boost 1.67boost 1.68boost 1.71
的行为相同 有人知道出了什么问题吗?

谢谢

我运行陷入了类似的问题。使用 runtime-debugging=on 或 off 构建将构建不带 g 标记的 .lib 文件。

b2 -a -j16 toolset=clang-win cxxflags="-D_CRT_SECURE_NO_WARNINGS -D_SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING" architecture=x86 address-model=64 runtime-link=static runtime-debugging=on --build-type=complete --layout=tagged variant=debug,release --without-mpi --without-python stage --stagedir=clangw10

会生成像 libboost_thread-mt-sd-x64.lib 这样的文件,而 link 反对它会破坏 linking 过程,如:

LINK Pass 1: command "C:\PROGRA~2\MICROS~119\COMMUN~1\VC\Tools\Llvm\bin\lld-link.exe CMakeFiles\test.dir\cmake_pch.cxx.obj CMakeFiles\test.dir\resources\win.rc.res CMakeFiles\test.dir\main.cpp.obj /out:test.exe /implib:test.lib /pdb:test.pdb /version:0.0 /machine:x64 /debug /INCREMENTAL /subsystem:windows E:\SDKs\boost_1_72_0\stage\lib\libboost_thread-mt-sd-x64.lib E:\SDKs\boost_1_72_0\stage\lib\libboost_chrono-mt-sd-x64.lib E:\SDKs\boost_1_72_0\stage\lib\libboost_date_time-mt-sd-x64.lib E:\SDKs\boost_1_72_0\stage\lib\libboost_atomic-mt-sd-x64.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:CMakeFiles\test.dir/intermediate.manifest CMakeFiles\test.dir/manifest.res" failed (exit code 1) with the following output:

E:\Workspace\test\build\x64-Debug\lld-link : error : could not open 'boost_thread-clangw10-mt-gd-x64-1_72.lib': no such file or directory

E:\Workspace\test\build\x64-Debug\lld-link : error : could not open 'libboost_date_time-clangw10-mt-gd-x64-1_72.lib': no such file or directory

E:\Workspace\test\build\x64-Debug\lld-link : error : could not open 'libboost_chrono-clangw10-mt-gd-x64-1_72.lib': no such file or directory

看起来这些库依赖于任何一种运行时调试,但没有 b2 能够产生那些我几乎坚持这一点。

更新 通过在 .lib 的文件名中添加 'g' 并使用 --layout=versioned[=17= 构建提升,我能够使用 cmake 成功 link 我的程序]

为了 link 我必须在 CMakeLists.txt

中添加正确的文件

set_property(TARGET ${PROJECT_NAME} PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")

问题似乎已在 version 1.74 中解决。我试过了 运行

b2 toolset=clang-win address-model=64 variant=debug --with-filesystem

生成文件:stage\lib\libboost_filesystem-clangw9-mt-gd-x64-1_74.lib,如预期。

如果您必须坚持使用增强版本,对我来说,只需重命名库文件也可以。或者,您可以跳过 auto-linking 并通过定义预处理器宏 BOOST_ALL_NO_LIB.

显式指定库