<div dir="ltr"><div><div>Hello LLVM Developers,<br></div>I am trying to compile the program in llvm/examples/ModuleMaker/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/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/examples/ModuleMaker/ModuleMaker.cpp:(.text.main+0x17): undefined reference to `llvm::LLVMContext::LLVMContext()'<br>/home/nabeel/src/llvm/examples/ModuleMaker/ModuleMaker.cpp:(.text.main+0x3b): undefined reference to `llvm::Module::Module(llvm::StringRef, llvm::LLVMContext&)'<br>/home/nabeel/src/llvm/examples/ModuleMaker/ModuleMaker.cpp:(.text.main+0x43): undefined reference to `llvm::Type::getInt32Ty(llvm::LLVMContext&)'<br>/home/nabeel/src/llvm/examples/ModuleMaker/ModuleMaker.cpp:(.text.main+0x4d): undefined reference to `llvm::FunctionType::get(llvm::Type*, bool)'<br>/home/nabeel/src/llvm/examples/ModuleMaker/ModuleMaker.cpp:(.text.main+0x70): undefined reference to `llvm::User::operator new(unsigned long)'<br>/home/nabeel/src/llvm/examples/ModuleMaker/ModuleMaker.cpp:(.text.main+0x88): undefined reference to `llvm::Function::Function(llvm::FunctionType*, llvm::GlobalValue::LinkageTypes, llvm::Twine const&, llvm::Module*)'<br>/home/nabeel/src/llvm/examples/ModuleMaker/ModuleMaker.cpp:(.text.main+0xc1): undefined reference to `llvm::BasicBlock::BasicBlock(llvm::LLVMContext&, llvm::Twine const&, llvm::Function*, llvm::BasicBlock*)'<br>/home/nabeel/src/llvm/examples/ModuleMaker/ModuleMaker.cpp:(.text.main+0xc9): undefined reference to `llvm::Type::getInt32Ty(llvm::LLVMContext&)'<br>/home/nabeel/src/llvm/examples/ModuleMaker/ModuleMaker.cpp:(.text.main+0xd8): undefined reference to `llvm::ConstantInt::get(llvm::IntegerType*, unsigned long, bool)'<br>/home/nabeel/src/llvm/examples/ModuleMaker/ModuleMaker.cpp:(.text.main+0xe3): undefined reference to `llvm::Type::getInt32Ty(llvm::LLVMContext&)'<br>/home/nabeel/src/llvm/examples/ModuleMaker/ModuleMaker.cpp:(.text.main+0xf2): undefined reference to `llvm::ConstantInt::get(llvm::IntegerType*, unsigned long, bool)'<br>/home/nabeel/src/llvm/examples/ModuleMaker/ModuleMaker.cpp:(.text.main+0x120): undefined reference to `llvm::BinaryOperator::Create(llvm::Instruction::BinaryOps, llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::Instruction*)'<br>/home/nabeel/src/llvm/examples/ModuleMaker/ModuleMaker.cpp:(.text.main+0x133): undefined reference to `llvm::SymbolTableListTraits<llvm::Instruction>::addNodeToList(llvm::Instruction*)'<br>/home/nabeel/src/llvm/examples/ModuleMaker/ModuleMaker.cpp:(.text.main+0x160): undefined reference to `llvm::User::operator new(unsigned long, unsigned int)'<br>/home/nabeel/src/llvm/examples/ModuleMaker/ModuleMaker.cpp:(.text.main+0x173): undefined reference to `llvm::ReturnInst::ReturnInst(llvm::LLVMContext&, llvm::Value*, llvm::Instruction*)'<br>/home/nabeel/src/llvm/examples/ModuleMaker/ModuleMaker.cpp:(.text.main+0x17e): undefined reference to `llvm::SymbolTableListTraits<llvm::Instruction>::addNodeToList(llvm::Instruction*)'<br>/home/nabeel/src/llvm/examples/ModuleMaker/ModuleMaker.cpp:(.text.main+0x19d): undefined reference to `llvm::outs()'<br>/home/nabeel/src/llvm/examples/ModuleMaker/ModuleMaker.cpp:(.text.main+0x1af): undefined reference to `llvm::WriteBitcodeToFile(llvm::Module const*, llvm::raw_ostream&, bool, llvm::ModuleSummaryIndex const*, bool)'<br>/home/nabeel/src/llvm/examples/ModuleMaker/ModuleMaker.cpp:(.text.main+0x1b7): undefined reference to `llvm::Module::~Module()'<br>/home/nabeel/src/llvm/examples/ModuleMaker/ModuleMaker.cpp:(.text.main+0x1c7): undefined reference to `llvm::LLVMContext::~LLVMContext()'<br>/tmp/ModuleMaker-f710af.o:(.data._ZN4llvm30VerifyDisableABIBreakingChecksE+0x0): undefined reference to `llvm::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.2.0<br>Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6<br>Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.2.0<br>Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/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="gmail_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>