如何使用llvm和g++进行编译?

3
我使用的是 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文件。所以我猜这可能是一个版本问题。 要怎么做才能使它工作?

有人能帮忙吗?先谢谢了... :)


Fedora 11已经相当老了,我建议你自己构建它或升级你的操作系统。Fedora 18已经发布,它的软件包肯定更加更新。 - rubenvb
2个回答

0

看起来头文件没有安装或者安装在你没有使用的路径上。我的建议是从llvm.org网站或svn下载代码,并使用它来构建Kaleidoscope示例。这相当简单,所有的代码都在examples目录中。


0

不要使用yum,可以通过这个或者这个链接来安装clang/llvm。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接