简体   繁体   English

无法在 VS2017 上将 libclang 与 cmake 链接

[英]Unable to link libclang with cmake on VS2017

A while ago I wrote a code generation program to use in my 3D game engine.不久前,我编写了一个代码生成程序,用于我的 3D 游戏引擎。 I added a target to my cmake files, linked libclang with it as I'm using that for parsing the code, and it all worked fine.我在我的 cmake 文件中添加了一个目标,将 libclang 与它链接起来,因为我正在使用它来解析代码,并且一切正常。 Recently I added another dependency to my project, wich in turn depends on SDL2.最近我在我的项目中添加了另一个依赖项,它又依赖于 SDL2。 After a lot of struggle I finally managed to get that to work, but suddenly the code generation project would no longer compile, even though I had literally not touched it in a few months.经过一番努力,我终于设法让它工作,但突然代码生成项目将不再编译,即使我实际上几个月都没有碰过它。 It fails to link, and starts giving errors about undefined symnols, even though I clearly specify the.lib file to link to and give it the correct path.它无法链接,并开始给出关于未定义符号的错误,即使我明确指定要链接的 .lib 文件并为其提供正确的路径。 Cmake files for my project are here .我的项目的 Cmake 文件在这里

I am using Cmake GUI on windows, generator VS2017 (x64), platform toolset LLVM.我在 windows、生成器 VS2017 (x64)、平台工具集 LLVM 上使用 Cmake GUI。

Any insights on this issue are greatly appreciated.非常感谢您对此问题的任何见解。

Update: The exact errors I'm getting are simply更新:我得到的确切错误只是

1>C:\Program Files (x86)\LLVM\bin\lld-link.exe : error : undefined symbol: __imp_clang_getTranslationUnitCursor
1>>>> referenced by C:\Users\michi_000\Desktop\C++\SaturnEngine\CodeGen\Serialization\main.cpp:128
1>>>>               SerializationCodeGen.dir\Editor\main.obj:(?get_cursor@TranslationUnit@@QEAA?AUCXCursor@@XZ)

For each libclang function I call.对于我调用的每个 libclang function。

The issue has been solved.问题已解决。 The problem was that my clang installation provided no import library for clang, and I was linking a static library instead.问题是我的 clang 安装没有为 clang 提供导入库,而我正在链接 static 库。 The headers expected an import library which caused it to fail.标头需要一个导致它失败的导入库。 I generated the import library from the dll and now it works fine.我从 dll 生成了导入库,现在它工作正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM