【问题标题】:lld-link error when compiling C++ project with Clang in Visual Studio 2019在 Visual Studio 2019 中使用 Clang 编译 C++ 项目时出现 lld-link 错误
【发布时间】:2021-10-26 12:00:08
【问题描述】:

我正忙于在 VS2019 中使用 Clang 编译我的项目,但我不能。 我将 VS2019 更新到最新版本,我现在正在使用 Clang 12.00。

在我的项目中,我使用的是 boost 库。为了构建 boost 库,我运行以下命令:

bootstrap --with-toolset=clang-win
b2.exe link=static threading=multi runtime-link=shared address-model=64 toolset=clang-win variant=release --build-type=complete --architecture=x64 cxxflags=-std=c++14

编译给了我这个错误:

1>lld-link : error : undefined symbol: __declspec(dllimport) public: __cdecl boost::thread::~thread(void)

我认为 boost 库不兼容。 VS 可以找到 boost 库,但我认为它无法读取其中的内容。

【问题讨论】:

标签: visual-c++ clang c++14


【解决方案1】:

答案是,当您使用带有 clang 的 boost 时,您应该在代码中设置 BOOST_THREAD_USE_LIB 标志。因此,我将以下 Cmake 代码添加到我的 CmakeListss.txt 文件中,我可以修复它。
add_definitions(-DBOOST_THREAD_USE_LIB)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-02-04
    • 1970-01-01
    • 2020-11-22
    • 1970-01-01
    • 1970-01-01
    • 2021-02-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多