Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ LLVM:VS 2015中的链接错误_C++_Windows_Llvm - Fatal编程技术网

C++ LLVM:VS 2015中的链接错误

C++ LLVM:VS 2015中的链接错误,c++,windows,llvm,C++,Windows,Llvm,我已经下载了源代码并使用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/Sou

我已经下载了源代码并使用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构建目录中的raw_ostream.obj

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


在我看来,包含LLVM lib目录是不够的。您还必须包括要链接的LLVM库(.lib,它实现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