使用Clang + CMake + Visual Studio运行程序会产生未定义的引用

时间:2019-02-15 22:21:41

标签: c++ visual-studio cmake llvm clang++

我正在尝试使用LLVM / Clang,Visual Studio和CMake来构建/运行一个简单的测试程序,但是每次尝试构建该项目时,我都会收到成千上万的错误消息:undefined reference ...或{{1 }}。

如果我构建包含所有... is ambiguousLLVM的库,则没有错误,但是当我构建包含我的库的程序时,我在{{1 }}标头。这使我相信我在可执行文件中缺少Clang的步骤。可能在构建可执行文件时应该链接llvm / clang库。

在我的库中,我只有一组llvm / clang包含(没有其他代码),在可执行文件中,我有一个空的main,其中一个包含到我的库中。

程序的命令行

LLVM

程序CMakeLists.txt

LLVM

CMakeSettings.json

[1/1] cmd.exe /C "cd . && C:\msys64\mingw64\bin\clang++.exe -g   rustynail/apps/introspection/CMakeFiles/RN_Introspection.dir/main.cpp.obj  -o D:\GameDevelopment\Projects\RustyNail_CMake\dev\rno\bin\RN_Introspection.exe -Wl,--out-implib,D:\GameDevelopment\Projects\RustyNail_CMake\dev\rno\lib\libRN_Introspection.dll.a -Wl,--major-image-version,0,--minor-image-version,0 -LD:/GameDevelopment/Projects/RustyNail_CMake/dev/rno/custom/shared D:/GameDevelopment/Projects/RustyNail_CMake/dev/rno/lib/UT.lib D:/GameDevelopment/Projects/RustyNail_CMake/dev/rno/lib/RTTI.lib -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ."
FAILED: D:/GameDevelopment/Projects/RustyNail_CMake/dev/rno/bin/RN_Introspection.exe 
cmd.exe /C "cd . && C:\msys64\mingw64\bin\clang++.exe -g   
rustynail/apps/introspection/CMakeFiles/RN_Introspection.dir/main.cpp.obj  -o D:\GameDevelopment\Projects\RustyNail_CMake\dev\rno\bin\RN_Introspection.exe -Wl,--out-implib,D:\GameDevelopment\Projects\RustyNail_CMake\dev\rno\lib\libRN_Introspection.dll.a -Wl,--major-image-version,0,--minor-image-version,0 -LD:/GameDevelopment/Projects/RustyNail_CMake/dev/rno/custom/shared D:/GameDevelopment/Projects/RustyNail_CMake/dev/rno/lib/UT.lib D:/GameDevelopment/Projects/RustyNail_CMake/dev/rno/lib/RTTI.lib -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ."
rustynail/apps/introspection/CMakeFiles/RN_Introspection.dir/main.cpp.obj: In function `clang::Decl::getAccess() const':
C:\msys64\mingw64\include\clang/AST/DeclBase.h:452: undefined reference to `clang::Decl::AccessDeclContextSanity() const'

<More similar errors but omitted for brevity>

0 个答案:

没有答案