Dyl*_*lon 5 g++ llvm bison flex-lexer
我一直在编写有关使用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
Run Code Online (Sandbox Code Playgroud)
据我所知,我有所有必要的包含和llvm-config脚本正常工作---有没有人知道如何解决这些错误?