<div dir="ltr"><div>You need your `llvm-config <stuff>` after the source file, so that it links in AFTER the source you are compiling - otherwise the linker will just skip over the whole library and say "well, nothing is using any of this, nothing is needed".<br><br>--<br></div>Mats<br></div><div class="gmail_extra"><br><div class="gmail_quote">On 11 April 2017 at 15:43, Nabeel Omer via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div>Hello LLVM Developers,<br></div>I am trying to compile the program in llvm/examples/ModuleMaker/<wbr>ModuleMaker.cpp.<br>I am executing the following command:<br><br>clang++ --std=c++14 `llvm-config --cxxflags --ldflags --libs --libfiles --system-libs` ~/src/llvm/examples/<wbr>ModuleMaker/ModuleMaker.cpp<br><br></div>The linker produces the following errors:<br><br>/tmp/ModuleMaker-f710af.o: In function `main':<br>/home/nabeel/src/llvm/<wbr>examples/ModuleMaker/<wbr>ModuleMaker.cpp:(.text.main+<wbr>0x17): undefined reference to `llvm::LLVMContext::<wbr>LLVMContext()'<br>/home/nabeel/src/llvm/<wbr>examples/ModuleMaker/<wbr>ModuleMaker.cpp:(.text.main+<wbr>0x3b): undefined reference to `llvm::Module::Module(llvm::<wbr>StringRef, llvm::LLVMContext&)'<br>/home/nabeel/src/llvm/<wbr>examples/ModuleMaker/<wbr>ModuleMaker.cpp:(.text.main+<wbr>0x43): undefined reference to `llvm::Type::getInt32Ty(llvm::<wbr>LLVMContext&)'<br>/home/nabeel/src/llvm/<wbr>examples/ModuleMaker/<wbr>ModuleMaker.cpp:(.text.main+<wbr>0x4d): undefined reference to `llvm::FunctionType::get(llvm:<wbr>:Type*, bool)'<br>/home/nabeel/src/llvm/<wbr>examples/ModuleMaker/<wbr>ModuleMaker.cpp:(.text.main+<wbr>0x70): undefined reference to `llvm::User::operator new(unsigned long)'<br>/home/nabeel/src/llvm/<wbr>examples/ModuleMaker/<wbr>ModuleMaker.cpp:(.text.main+<wbr>0x88): undefined reference to `llvm::Function::Function(<wbr>llvm::FunctionType*, llvm::GlobalValue::<wbr>LinkageTypes, llvm::Twine const&, llvm::Module*)'<br>/home/nabeel/src/llvm/<wbr>examples/ModuleMaker/<wbr>ModuleMaker.cpp:(.text.main+<wbr>0xc1): undefined reference to `llvm::BasicBlock::BasicBlock(<wbr>llvm::LLVMContext&, llvm::Twine const&, llvm::Function*, llvm::BasicBlock*)'<br>/home/nabeel/src/llvm/<wbr>examples/ModuleMaker/<wbr>ModuleMaker.cpp:(.text.main+<wbr>0xc9): undefined reference to `llvm::Type::getInt32Ty(llvm::<wbr>LLVMContext&)'<br>/home/nabeel/src/llvm/<wbr>examples/ModuleMaker/<wbr>ModuleMaker.cpp:(.text.main+<wbr>0xd8): undefined reference to `llvm::ConstantInt::get(llvm::<wbr>IntegerType*, unsigned long, bool)'<br>/home/nabeel/src/llvm/<wbr>examples/ModuleMaker/<wbr>ModuleMaker.cpp:(.text.main+<wbr>0xe3): undefined reference to `llvm::Type::getInt32Ty(llvm::<wbr>LLVMContext&)'<br>/home/nabeel/src/llvm/<wbr>examples/ModuleMaker/<wbr>ModuleMaker.cpp:(.text.main+<wbr>0xf2): undefined reference to `llvm::ConstantInt::get(llvm::<wbr>IntegerType*, unsigned long, bool)'<br>/home/nabeel/src/llvm/<wbr>examples/ModuleMaker/<wbr>ModuleMaker.cpp:(.text.main+<wbr>0x120): undefined reference to `llvm::BinaryOperator::Create(<wbr>llvm::Instruction::BinaryOps, llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::Instruction*)'<br>/home/nabeel/src/llvm/<wbr>examples/ModuleMaker/<wbr>ModuleMaker.cpp:(.text.main+<wbr>0x133): undefined reference to `llvm::SymbolTableListTraits<<wbr>llvm::Instruction>::<wbr>addNodeToList(llvm::<wbr>Instruction*)'<br>/home/nabeel/src/llvm/<wbr>examples/ModuleMaker/<wbr>ModuleMaker.cpp:(.text.main+<wbr>0x160): undefined reference to `llvm::User::operator new(unsigned long, unsigned int)'<br>/home/nabeel/src/llvm/<wbr>examples/ModuleMaker/<wbr>ModuleMaker.cpp:(.text.main+<wbr>0x173): undefined reference to `llvm::ReturnInst::ReturnInst(<wbr>llvm::LLVMContext&, llvm::Value*, llvm::Instruction*)'<br>/home/nabeel/src/llvm/<wbr>examples/ModuleMaker/<wbr>ModuleMaker.cpp:(.text.main+<wbr>0x17e): undefined reference to `llvm::SymbolTableListTraits<<wbr>llvm::Instruction>::<wbr>addNodeToList(llvm::<wbr>Instruction*)'<br>/home/nabeel/src/llvm/<wbr>examples/ModuleMaker/<wbr>ModuleMaker.cpp:(.text.main+<wbr>0x19d): undefined reference to `llvm::outs()'<br>/home/nabeel/src/llvm/<wbr>examples/ModuleMaker/<wbr>ModuleMaker.cpp:(.text.main+<wbr>0x1af): undefined reference to `llvm::WriteBitcodeToFile(<wbr>llvm::Module const*, llvm::raw_ostream&, bool, llvm::ModuleSummaryIndex const*, bool)'<br>/home/nabeel/src/llvm/<wbr>examples/ModuleMaker/<wbr>ModuleMaker.cpp:(.text.main+<wbr>0x1b7): undefined reference to `llvm::Module::~Module()'<br>/home/nabeel/src/llvm/<wbr>examples/ModuleMaker/<wbr>ModuleMaker.cpp:(.text.main+<wbr>0x1c7): undefined reference to `llvm::LLVMContext::~<wbr>LLVMContext()'<br>/tmp/ModuleMaker-f710af.o:(.<wbr>data._<wbr>ZN4llvm30VerifyDisableABIBreak<wbr>ingChecksE+0x0): undefined reference to `llvm::<wbr>DisableABIBreakingChecks'<br>clang-4.0: error: linker command failed with exit code 1 (use -v to see invocation)<br>Makefile:2: recipe for target 'all' failed<br>make: *** [all] Error 1<br><br><div>The output of `clang -v`:<br><br>clang version 4.0.0 (tags/RELEASE_400/final)<br>Target: x86_64-unknown-linux-gnu<br>Thread model: posix<br>InstalledDir: /home/nabeel/bin/clang/bin<br>Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/6<br>Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/6.<wbr>2.0<br>Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/<wbr>6<br>Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/<wbr>6.2.0<br>Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/<wbr>6.2.0<br>Candidate multilib: .;@m64<br>Selected multilib: .;@m64<br><br></div><div>From what I understand, there should be no linker errors because llvm-config produces the names of all the libraries that are distributed with LLVM.<br><br></div><div>Any help will be enormously appreciated.<br></div><div><br clear="all"><div><div><div><div class="m_-823459660002028232gmail_signature"><div dir="ltr"><div>Nabeel Omer<br>Systems Programmer, Undergraduate Student, Aspiring Computer Scientist<br></div><div><a href="https://nabeelomer.github.io" target="_blank">https://nabeelomer.github.io</a><br></div><div><a href="http://nabeelomer.xyz" target="_blank"></a></div></div></div></div>
</div></div></div></div>
<br>______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
<br></blockquote></div><br></div>