gpt4 book ai didi

c++ - LLVM:VS 2015中的链接错误

转载 作者:行者123 更新时间:2023-12-01 14:55:25 25 4
gpt4 key购买 nike

我已经下载了源代码,并使用CMake和VS 2015构建了LLVM。

我的示例程序如下:

#include <iostream>

#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/CFG.h"
#include "llvm/IRReader/IRReader.h"
#include "llvm/Support/SourceMgr.h"
#include "llvm/Support/raw_ostream.h"

using namespace llvm;

int main(int argc, char **argv) {
if (argc < 2) {
errs() << "Usage: " << argv[0] << " <IR file>\n";
return 1;
}

// Parse the input LLVM IR file into a module.
SMDiagnostic Err;
LLVMContext TheContext;
std::unique_ptr<Module> Mod = parseIRFile(argv[1], Err, TheContext);
if (!Mod) {
Err.print(argv[0], errs());
return 1;
}

// ... use module
}

在链接器库路径中包含LLVM lib目录后,出现以下链接错误:
Severity    Code    Description Project File    Line    Suppression State
Error LNK2019 unresolved external symbol "public: __thiscall llvm::LLVMContext::LLVMContext(void)" (??0LLVMContext@llvm@@QAE@XZ) referenced in function _main LLVM_IRReader c:\Users\nlykkei\documents\visual studio 2015\Projects\LLVM_IRReader\LLVM_IRReader\Main.obj 1

Severity Code Description Project File Line Suppression State
Error LNK2019 unresolved external symbol "public: __thiscall llvm::Module::~Module(void)" (??1Module@llvm@@QAE@XZ) referenced in function "public: void * __thiscall llvm::Module::`scalar deleting destructor'(unsigned int)" (??_GModule@llvm@@QAEPAXI@Z) LLVM_IRReader c:\Users\nlykkei\documents\visual studio 2015\Projects\LLVM_IRReader\LLVM_IRReader\Main.obj 1

Severity Code Description Project File Line Suppression State
Error LNK2019 unresolved external symbol "class llvm::raw_ostream & __cdecl llvm::errs(void)" (?errs@llvm@@YAAAVraw_ostream@1@XZ) referenced in function _main LLVM_IRReader c:\Users\nlykkei\documents\visual studio 2015\Projects\LLVM_IRReader\LLVM_IRReader\Main.obj 1

Severity Code Description Project File Line Suppression State
Error LNK2019 unresolved external symbol "public: void __thiscall llvm::SMDiagnostic::print(char const *,class llvm::raw_ostream &,bool,bool)const " (?print@SMDiagnostic@llvm@@QBEXPBDAAVraw_ostream@2@_N2@Z) referenced in function _main LLVM_IRReader c:\Users\nlykkei\documents\visual studio 2015\Projects\LLVM_IRReader\LLVM_IRReader\Main.obj 1

有谁知道如何解决这些错误?我在LLVM构建目录中看到例如raw_ostream.obj ...

最佳答案

我从未使用过LLVM,但根据您的错误消息,链接器未成功找到LLVM类的实现。

以我的观点,仅包括LLVM lib目录是不够的。您还必须包括要链接的LLVM库(实现LLVM类的.lib)。

关于c++ - LLVM:VS 2015中的链接错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41649407/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com