Hi! I'm trying to learn LLVM and I want to compile the Kaleidoscope compiler. according to: http://llvm.org/docs/tutorial/LangImpl3.html I'm compiling it with: clang++ -g -O3 test.cpp `llvm-config --cppflags --ldflags --libs core` -o toy and it indeed works. The problem is that when using eclipse it forces me to divide the compilation into two steps: g++ -O0 -g3 -Wall -c -fmessage-length=0 `llvm-config --cppflags --ldflags --libs core` -MMD -MP -MF"src/lunac.d" -MT"src/lunac.d" -o "src/test.o" "../src/test.cpp" (which compiles fine) and: Invoking: Cross G++ Linker g++ `llvm-config --cppflags --ldflags --libs core` -o "test" ./src/test.o which gives me error: ./src/test.o: In function `NumberExprAST::Codegen()': /home/wdanilo/dev/lunac/Debug/../src/test.cpp:358: undefined reference to `llvm::APFloat::APFloat(double)' /home/wdanilo/dev/lunac/Debug/../src/test.cpp:358: undefined reference to `llvm::getGlobalContext()' /home/wdanilo/dev/lunac/Debug/../src/test.cpp:358: undefined reference to `llvm::ConstantFP::get(llvm::LLVMContext&, llvm::APFloat const&)' [...] Why Linker is not working with these flags? How can I fix it? -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20121106/1e473e9f/attachment.html>
In the previous mail there was little bug, the code executed by eclipse to compile the .o file was: g++ -O0 -g3 -Wall -c -fmessage-length=0 `llvm-config --cppflags --ldflags --libs core` -MMD -MP -MF"src/test.d" -MT"src/test.d" -o "src/test.o" "../src/test.cpp" (which compiles fine) 2012/11/6 Wojciech Daniło <wojtek.danilo.ml at gmail.com>> Hi! > I'm trying to learn LLVM and I want to compile the Kaleidoscope compiler. > according to: > http://llvm.org/docs/tutorial/LangImpl3.html > > I'm compiling it with: > clang++ -g -O3 test.cpp `llvm-config --cppflags --ldflags --libs core` -o > toy > > and it indeed works. > The problem is that when using eclipse it forces me to divide the > compilation into two steps: > > g++ -O0 -g3 -Wall -c -fmessage-length=0 `llvm-config --cppflags --ldflags > --libs core` -MMD -MP -MF"src/lunac.d" -MT"src/lunac.d" -o "src/test.o" > "../src/test.cpp" > (which compiles fine) > > and: > > Invoking: Cross G++ Linker > g++ `llvm-config --cppflags --ldflags --libs core` -o "test" ./src/test.o > > which gives me error: > ./src/test.o: In function `NumberExprAST::Codegen()': > /home/wdanilo/dev/lunac/Debug/../src/test.cpp:358: undefined reference to > `llvm::APFloat::APFloat(double)' > /home/wdanilo/dev/lunac/Debug/../src/test.cpp:358: undefined reference to > `llvm::getGlobalContext()' > /home/wdanilo/dev/lunac/Debug/../src/test.cpp:358: undefined reference to > `llvm::ConstantFP::get(llvm::LLVMContext&, llvm::APFloat const&)' > [...] > > Why Linker is not working with these flags? How can I fix it? > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20121106/e9b0c7e6/attachment.html>
On Tue, Nov 6, 2012 at 6:38 AM, Wojciech Daniło <wojtek.danilo.ml at gmail.com> wrote:> Hi! > I'm trying to learn LLVM and I want to compile the Kaleidoscope compiler. > according to: > http://llvm.org/docs/tutorial/LangImpl3.html > > I'm compiling it with: > clang++ -g -O3 test.cpp `llvm-config --cppflags --ldflags --libs core` -o > toy > > and it indeed works. > The problem is that when using eclipse it forces me to divide the > compilation into two steps: > > g++ -O0 -g3 -Wall -c -fmessage-length=0 `llvm-config --cppflags --ldflags > --libs core` -MMD -MP -MF"src/lunac.d" -MT"src/lunac.d" -o "src/test.o" > "../src/test.cpp" > (which compiles fine) > > and: > > Invoking: Cross G++ Linker > g++ `llvm-config --cppflags --ldflags --libs core` -o "test" ./src/test.o > > which gives me error: > ./src/test.o: In function `NumberExprAST::Codegen()': > /home/wdanilo/dev/lunac/Debug/../src/test.cpp:358: undefined reference to > `llvm::APFloat::APFloat(double)' > /home/wdanilo/dev/lunac/Debug/../src/test.cpp:358: undefined reference to > `llvm::getGlobalContext()' > /home/wdanilo/dev/lunac/Debug/../src/test.cpp:358: undefined reference to > `llvm::ConstantFP::get(llvm::LLVMContext&, llvm::APFloat const&)' > [...] > > Why Linker is not working with these flags? How can I fix it?When you're passing arguments to the linker, the order matters. Try reordering the command-line so test.o comes first. -Eli
Thank you, it works! :) 2012/11/6 Eli Friedman <eli.friedman at gmail.com>> On Tue, Nov 6, 2012 at 6:38 AM, Wojciech Daniło > <wojtek.danilo.ml at gmail.com> wrote: > > Hi! > > I'm trying to learn LLVM and I want to compile the Kaleidoscope compiler. > > according to: > > http://llvm.org/docs/tutorial/LangImpl3.html > > > > I'm compiling it with: > > clang++ -g -O3 test.cpp `llvm-config --cppflags --ldflags --libs core` -o > > toy > > > > and it indeed works. > > The problem is that when using eclipse it forces me to divide the > > compilation into two steps: > > > > g++ -O0 -g3 -Wall -c -fmessage-length=0 `llvm-config --cppflags --ldflags > > --libs core` -MMD -MP -MF"src/lunac.d" -MT"src/lunac.d" -o "src/test.o" > > "../src/test.cpp" > > (which compiles fine) > > > > and: > > > > Invoking: Cross G++ Linker > > g++ `llvm-config --cppflags --ldflags --libs core` -o "test" > ./src/test.o > > > > which gives me error: > > ./src/test.o: In function `NumberExprAST::Codegen()': > > /home/wdanilo/dev/lunac/Debug/../src/test.cpp:358: undefined reference to > > `llvm::APFloat::APFloat(double)' > > /home/wdanilo/dev/lunac/Debug/../src/test.cpp:358: undefined reference to > > `llvm::getGlobalContext()' > > /home/wdanilo/dev/lunac/Debug/../src/test.cpp:358: undefined reference to > > `llvm::ConstantFP::get(llvm::LLVMContext&, llvm::APFloat const&)' > > [...] > > > > Why Linker is not working with these flags? How can I fix it? > > When you're passing arguments to the linker, the order matters. Try > reordering the command-line so test.o comes first. > > -Eli >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20121107/46bcce70/attachment.html>