雷明亮
2015-Jul-07 13:34 UTC
[LLVMdev] Link error when I compile the Toy(kaleidoscope) example
Hi All, I check out the LLVM code and compile, install it by below commands:>mkdir build & cd build >cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release ../ >make -j4 >make installThen I copy the source code from http://llvm.org/docs/tutorial/LangImpl3.html And run the command as it showed: # Compile clang++ -g -O3 toy.cpp `llvm-config --cxxflags --ldflags --system-libs --libs core` -o toy # Run ./toy Then I got the follow error: ------------------------------------------------------------------------------------------------------------- clang version 3.7.0 (trunk 241442) Target: x86_64-unknown-linux-gnu Thread model: posix Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.8 Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.8.4 Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.9 Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.9.1 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6.4 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.4 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9.1 Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8 Candidate multilib: .;@m64 Selected multilib: .;@m64 "/usr/local/bin/clang-3.7" -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -disable-free -disable-llvm-verifier -main-file-name toy.cpp -mrelocation-model pic -pic-level 2 -mthread-model posix -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -momit-leaf-frame-pointer -v -dwarf-column-info -ffunction-sections -fdata-sections -resource-dir /usr/local/bin/../lib/clang/3.7.0 -D NDEBUG -D _GNU_SOURCE -D __STDC_CONSTANT_MACROS -D __STDC_FORMAT_MACROS -D __STDC_LIMIT_MACROS -I /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/x86_64-linux-gnu/c++/4.8 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/x86_64-linux-gnu/c++/4.8 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/backward -internal-isystem /usr/local/include -internal-isystem /usr/local/bin/../lib/clang/3.7.0/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O3 -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -Wno-long-long -Wno-maybe-uninitialized -Wno-comment -pedantic -std=c++11 -fdeprecated-macro -fdebug-compilation-dir /home/mingliang/workspace/learning/llvm/kaleidoscope -ferror-limit 19 -fmessage-length 239 -fvisibility-inlines-hidden -mstackrealign -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -vectorize-loops -vectorize-slp -o /tmp/toy-4d46c9.o -x c++ toy.cpp warning: unknown warning option '-Wno-maybe-uninitialized'; did you mean '-Wno-uninitialized'? [-Wunknown-warning-option] clang -cc1 version 3.7.0 based upon LLVM 3.7.0svn default target x86_64-unknown-linux-gnu ignoring nonexistent directory "/include" ignoring duplicate directory "/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/x86_64-linux-gnu/c++/4.8" ignoring duplicate directory "/usr/local/include" as it is a non-system directory that duplicates a system directory #include "..." search starts here: #include <...> search starts here: /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8 /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/x86_64-linux-gnu/c++/4.8 /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/backward /usr/local/include /usr/local/bin/../lib/clang/3.7.0/include /usr/include/x86_64-linux-gnu /usr/include End of search list. 1 warning generated. "/usr/bin/ld" -z relro --hash-style=gnu --build-id --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o toy /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crt1.o /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/4.8/crtbegin.o -L/usr/local/lib -L/usr/lib/gcc/x86_64-linux-gnu/4.8 -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu -L/lib/x86_64-linux-gnu -L/lib/../lib64 -L/usr/lib/x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../.. -L/usr/local/bin/../lib -L/lib -L/usr/lib /tmp/toy-4d46c9.o -lLLVMCore -lLLVMSupport -lrt -ldl -ltinfo -lpthread -lm -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/x86_64-linux-gnu/4.8/crtend.o /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crtn.o /tmp/toy-4d46c9.o:(.data.rel.ro._ZTIN4llvm8FCmpInstE[_ZTIN4llvm8FCmpInstE]+0x10): undefined reference to `typeinfo for llvm::CmpInst' clang-3.7: error: linker command failed with exit code 1 (use -v to see invocation) Could you please help solve this issue? Thanks. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150707/fd0e886f/attachment.html>
Tim Northover
2015-Jul-07 19:10 UTC
[LLVMdev] Link error when I compile the Toy(kaleidoscope) example
> undefined reference to `typeinfo for llvm::CmpInst' > clang-3.7: error: linker command failed with exit code 1 (use -v to see > invocation)Looks like an error from the toy being built with -frtti but LLVM with -fno-rtti. Try this if you're not actually using the typeinfo: $ clang++ -g -O3 toy.cpp `llvm-config --cxxflags --ldflags --system-libs --libs core` -fno-rtti -o toy I've never been quite sure why that flag isn't part of "llvm-config --cxxflags". Tim.