Hi,
I'm playing around with llvm and the Kaleidoscope tutorial and first of
all I have to say I'm really impressed. LLVM rocks!
Unfortunately I've now run into a linker error while trying to optimize
the IR or turn it to bitcode and likely due to my very limited
experience with c++ I just can't figure out how to resolve it.
The linker complains that the llvm::WriteBitcodeToFile function is
undefined, although I included llvm/Bitcode/ReaderWriter.h:
undefined reference to `llvm::WriteBitcodeToFile(llvm::Module const*,
std::basic_ostream<char, std::char_traits<char> >&)
I also get the same undefined reference error if I call the
llvm::createXXXPass and llvm::verifyXXX functions although I included
all the files like in the Kaleidoscope tutorial.
Everything else works fine though.
I'm compiling my project with gcc-4.2 and llvm-config with --libs all
and I'm using the RELEASE_22 tag from subversion and Eclipse CDT with
managed make (on Ubuntu 32bit).
This is the full command that's executed to link the project and its output:
g++-4.2 `/home/stefan/projects/llvm/Debug/bin/llvm-config --ldflags
--libs` `pkg-config --libs glibmm-2.4` -o"mojo" ./src/mojo.o
./src/mojo/lexer/state/Comment.o ./src/mojo/lexer/state/Default.o
./src/mojo/lexer/state/Numeric.o ./src/mojo/lexer/state/String.o
./src/mojo/lexer/Scanner.o ./src/mojo/lexer/Token.o
./src/mojo/ast/BinaryOperator.o ./src/mojo/ast/ConditionalBlock.o
./src/mojo/ast/FloatingPoint.o ./src/mojo/ast/Function.o
./src/mojo/ast/Integer.o ./src/mojo/ast/Invocation.o
./src/mojo/ast/Statement.o ./src/mojo/ast/Variable.o
./src/mojo/ast/WhileBlock.o ./src/mojo/IR.o ./src/mojo/Parser.o
./src/mojo.o: In function
`writeBitCode(mojo::lexer::input::Interface&)':
/home/stefan/projects/mojo2/Debug/../src/mojo.cc:140: undefined
reference to `llvm::WriteBitcodeToFile(llvm::Module const*,
std::basic_ostream<char, std::char_traits<char> >&)'
collect2: ld gab 1 als Ende-Status zurück
make: *** [mojo] Fehler 1
What am I missing?
thanks in advance,
Stefan Oestreicher