【问题标题】:Linking errors when trying to link libclang in Visual Studio尝试在 Visual Studio 中链接 libclang 时出现链接错误
【发布时间】:2015-10-19 21:00:24
【问题描述】:

我想做的是构建这个库: https://github.com/AustinBrunkhorst/CPP-Reflection 一切都很顺利,直到我链接到发生这种情况的 libclang:

1>Cursor.obj : error LNK2001: unresolved external symbol __imp_clang_CXXMethod_isStatic
1>Cursor.obj : error LNK2001: unresolved external symbol __imp_clang_getCursorType
1>Cursor.obj : error LNK2001: unresolved external symbol __imp_clang_Cursor_getMangling
1>Cursor.obj : error LNK2001: unresolved external symbol __imp_clang_getCXXAccessSpecifier
1>Cursor.obj : error LNK2001: unresolved external symbol __imp_clang_Cursor_getStorageClass
1>Cursor.obj : error LNK2001: unresolved external symbol __imp_clang_getCursorSpelling
1>Cursor.obj : error LNK2001: unresolved external symbol __imp_clang_visitChildren
1>Cursor.obj : error LNK2001: unresolved external symbol __imp_clang_getTypedefDeclUnderlyingType
1>Cursor.obj : error LNK2001: unresolved external symbol __imp_clang_getCursorDisplayName
1>Cursor.obj : error LNK2001: unresolved external symbol __imp_clang_CXXMethod_isConst
1>Cursor.obj : error LNK2001: unresolved external symbol __imp_clang_isCursorDefinition
1>Cursor.obj : error LNK2001: unresolved external symbol __imp_clang_getCursorLexicalParent
1>Cursor.obj : error LNK2001: unresolved external symbol __imp_clang_getCursorResultType
1>CursorType.obj : error LNK2001: unresolved external symbol __imp_clang_isConstQualifiedType
1>CursorType.obj : error LNK2001: unresolved external symbol __imp_clang_getNumArgTypes
1>CursorType.obj : error LNK2001: unresolved external symbol __imp_clang_getTypeDeclaration
1>CursorType.obj : error LNK2001: unresolved external symbol __imp_clang_getTypeSpelling
1>CursorType.obj : error LNK2001: unresolved external symbol __imp_clang_getArgType
1>CursorType.obj : error LNK2001: unresolved external symbol __imp_clang_getCanonicalType
1>MetaUtils.obj : error LNK2001: unresolved external symbol __imp_clang_disposeString
1>MetaUtils.obj : error LNK2001: unresolved external symbol __imp_clang_getCString
1>ReflectionParser.obj : error LNK2001: unresolved external symbol __imp_clang_getTranslationUnitCursor
1>ReflectionParser.obj : error LNK2001: unresolved external symbol __imp_clang_createTranslationUnitFromSourceFile
1>ReflectionParser.obj : error LNK2001: unresolved external symbol __imp_clang_createIndex
1>ReflectionParser.obj : error LNK2001: unresolved external symbol __imp_clang_disposeIndex
1>ReflectionParser.obj : error LNK2001: unresolved external symbol __imp_clang_disposeTranslationUnit

我正在构建 64 位版本,并且我也以 64 位/发布模式从源手动构建 llvm/clang。 我不知道这是否重要(?),但我正在使用来自 github 的 clang 的 master 分支。考虑到一切都经过了链接阶段,我认为,master 分支应该一切正常。

我正在使用 Visual Stduio 2015。

在项目选项中,我添加了附加库目录以指向 clang 具有 *.lib 文件的位置。

【问题讨论】:

    标签: c++ dll linker clang visual-studio-2015


    【解决方案1】:

    除了在Linker ->additional library directories 中指定它们的路径外,您还需要在属性对话框的Linker->Input->Additional Dependencies 部分中明确列出您要链接到的特定.lib 文件。

    另外,再次检查您的 lib 文件路径和版本是否正确(x86 与 x64)。

    在没有 lib 文件的情况下,链接器无法将名称(符号)解析为它们的实现,因此出现 unresolved symbol 链接器错误。

    如果您有兴趣进一步了解,这里有一个很好的资源 - http://www.lurklurk.org/linkers/linkers.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-01-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-21
      • 2011-04-16
      • 1970-01-01
      相关资源
      最近更新 更多