如何用llvm和g ++编译?

时间:2010-04-02 09:39:58

标签: c++ llvm

我使用fedora-11系统,最近我安装了llvm(sudo yum -y install llvm llvm-docs llvm-devel)。 当我搜索llvm时,我会在/usr/bin中找到它们。二进制文件的某些链接已损坏(llvm-gccllvm-g++llvm-cpp等。包含文件位于/usr/include/llvm/usr/lib/llvm的库中。如何使用g++编译它们?我按照指示尝试编译tutorial中给出的万花筒代码,但无法编译。

我明白了:

toy.cpp:5:30: error: llvm/LLVMContext.h: No such file or directory

toy.cpp:352: error: ‘getGlobalContext’ was not declared in this scope

toy.cpp: In member function ‘virtual llvm::Value* NumberExprAST::Codegen()’:

toy.cpp:358: error: ‘getGlobalContext’ was not declared in this scope

toy.cpp: In member function ‘virtual llvm::Value* BinaryExprAST::Codegen()’:

toy.cpp:379: error: ‘getDoubleTy’ is not a member of ‘llvm::Type’

toy.cpp:379: error: ‘getGlobalContext’ was not declared in this scope

toy.cpp: In member function ‘llvm::Function* PrototypeAST::Codegen()’:

toy.cpp:407: error: ‘getDoubleTy’ is not a member of ‘llvm::Type’

toy.cpp:407: error: ‘getGlobalContext’ was not declared in this scope

toy.cpp:408: error: ‘getDoubleTy’ is not a member of ‘llvm::Type’

toy.cpp: In member function ‘llvm::Function* FunctionAST::Codegen()’:

toy.cpp:454: error: ‘getGlobalContext’ was not declared in this scope

toy.cpp: In function ‘int main()’:

toy.cpp:543: error: ‘LLVMContext’ was not declared in this scope

toy.cpp:543: error: ‘Context’ was not declared in this scope

toy.cpp:543: error: ‘getGlobalContext’ was not declared in this scope

我也找不到LLVMContext.h文件。所以我想这可能是一个版本问题。 我该怎么做才能让它发挥作用?

一些帮助会很好!在此先感谢... :)

2 个答案:

答案 0 :(得分:0)

看起来标题未安装或未安装在您未使用的路径中。我的建议是从llvm.org网站或svn下载代码并使用它来构建Kaleidoscope示例。它非常简单,所有代码都在examples目录中。

答案 1 :(得分:0)

不是使用yum,而是按照thisthis链接安装clang / llvm。