gpt4 book ai didi

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

转载 作者:太空狗 更新时间:2023-10-29 23:20:14 25 4
gpt4 key购买 nike

我使用的是 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 文件。所以我猜这可能是版本问题。我应该怎么做才能让它发挥作用?

一些帮助会很好!提前致谢...:)

最佳答案

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

关于c++ - 如何使用 llvm 和 g++ 进行编译?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2565960/

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