You are not logged in.

#1 2011-03-05 23:53:15

deltaecho
Member
From: Georgia (USA)
Registered: 2008-08-06
Posts: 193

[SOLVED] Trouble linking against LLVM libs + Flex and Bison

I've been working through a tutorial on writing compilers with Flex, Bison, and LLVM (http://gnuu.org/2009/09/18/writing-your … -compiler/), and attempting to compile the final binary fails with many of the following "undefined reference" errors:

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

As far as I know, I have all the necessary includes and the llvm-config script is working correctly --- does anybody have any idea how to resolve these errors?

EDIT: I needed to move the lib includes after the source files tongue  Now, I feel like a dummy --- anyway, thanks to @Chris Dodd on StackOverflow for the solution (link to thread: http://stackoverflow.com/questions/5207 … and-bison).

Last edited by deltaecho (2011-03-06 03:37:54)


Dylon

Offline

#2 2013-09-06 11:44:27

itlodge
Member
Registered: 2013-03-27
Posts: 3

Re: [SOLVED] Trouble linking against LLVM libs + Flex and Bison

I met the same problem and the link solved it. Thanks a lot!

Offline

#3 2013-09-06 17:06:59

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 20,488

Re: [SOLVED] Trouble linking against LLVM libs + Flex and Bison

2 years on, I think we can close this thread now.


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
The shortest way to ruin a country is to give power to demagogues.— Dionysius of Halicarnassus
---
How to Ask Questions the Smart Way

Offline

Board footer

Powered by FluxBB