簡體   English   中英

如何使用“clang-win”工具集構建調試提升靜態庫?

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

我在使用clang-win工具集構建標准和運行時支持庫的調試版本時遇到問題(使用msvc工具集一切正常)

具體來說,我正在嘗試構建 lib 文件的mt-gd變體,因此我添加了runtime-debugging=on開關,如Boost 文檔所說但無濟於事
這是我得到的:

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 Pass 1: command "C:\\PROGRA~2\\MICROS~1\\2019\\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構建 boost 成功地將我的程序與 cmake 鏈接起來

為了鏈接正確的文件,我必須在CMakeLists.txt 中添加

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

該問題似乎已在1.74 版中解決。 我試過跑步

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

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

如果您必須堅持使用 boost 版本,對我來說,只需重命名庫文件也行。 或者,您可以跳過自動鏈接並通過定義預處理器宏BOOST_ALL_NO_LIB顯式指定庫。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM