与包含 Flex 和 Bison 的项目链接 LLVM 时遇到问题

2023-12-08

我一直在学习使用 Flex、Bison 和 LLVM 编写编译器的教程(http://gnuu.org/2009/09/18/writing-your-own-toy-compiler/),并尝试编译最终的二进制文件失败,并出现许多以下“未定义的引用”错误:

g++ -o parser `llvm-config --libs core jit native --cxxflags --ldflags` *.cpp
/tmp/ccl0CSyi.o: In function `NBinaryOperator::codeGen(CodeGenContext&)':
codegen.cpp:(.text+0x2ce): undefined reference to     `llvm::BinaryOperator::Create(llvm::Instruction::BinaryOps, llvm::Value*, llvm::Value*,     llvm::Twine const&, llvm::BasicBlock*)'
/tmp/ccl0CSyi.o: In function `NDouble::codeGen(CodeGenContext&)':
codegen.cpp:(.text+0x3db): undefined reference to `llvm::getGlobalContext()'
codegen.cpp:(.text+0x3e3): undefined reference to     `llvm::Type::getDoubleTy(llvm::LLVMContext&)'
/tmp/ccl0CSyi.o: In function `NInteger::codeGen(CodeGenContext&)':
...
collect2: ld returned 1 exit status
make: *** [parser] Error 1

据我所知,我拥有所有必要的内容,并且 llvm-config 脚本工作正常 --- 有人知道如何解决这些错误吗?


您需要将库放在命令行上的源文件之后

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

与包含 Flex 和 Bison 的项目链接 LLVM 时遇到问题 的相关文章

随机推荐