I'm trying to start a project based on llvm, but am running into some difficulties. I started with the 'LLVM Project Guide', but got hung up in the complexities of configure.ac. I'm now using llvm-config to provide the linker directives, but this results in undefined references: $ llvm-g++ `$HOME/local/bin/llvm-config --cppflags --ldflags --libs bitwriter` ModuleMaker.cpp Yields: /tmp/ccjh9OY1.o: In function `main': ModuleMaker.cpp:(.text+0x13): undefined reference to `llvm::LLVMContext::LLVMContext()' ModuleMaker.cpp:(.text+0x66): undefined reference to `llvm::Module::Module(llvm::StringRef, llvm::LLVMContext&)' ModuleMaker.cpp:(.text+0x7a): undefined reference to `llvm::Type::getInt32Ty(llvm::LLVMContext&)' ... For reference: $ $HOME/local/bin/llvm-config --cppflags --ldflags --libs bitwriter -I/home/e0082888/local/include -D_DEBUG -D_GNU_SOURCE -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -L/home/e0082888/local/lib -lpthread -ldl -lm -lLLVMBitWriter -lLLVMCore -lLLVMSupport -lLLVMSystem I also get the same result if I remove 'bitwriter' from the llvm-config argument list so as to link with all libraries. Any suggestions? BTW, my llvm-g++ is from a ubuntu package, whereas as the libraries I'm attempting to link against (2.7) were compiled and installed locally. I've also tried g++ in place of llvm-g++, but the results are the same. Thanks for any help. -Tom
Hi Tom,> I'm trying to start a project based on llvm, but am running into some > difficulties. I started with the 'LLVM Project Guide', but got hung > up in the complexities of configure.ac. I'm now using llvm-config to > provide the linker directives, but this results in undefined > references: > > $ llvm-g++ `$HOME/local/bin/llvm-config --cppflags --ldflags --libs > bitwriter` ModuleMaker.cpp > > Yields: > > /tmp/ccjh9OY1.o: In function `main': > ModuleMaker.cpp:(.text+0x13): undefined reference to > `llvm::LLVMContext::LLVMContext()' > ModuleMaker.cpp:(.text+0x66): undefined reference to > `llvm::Module::Module(llvm::StringRef, llvm::LLVMContext&)' > ModuleMaker.cpp:(.text+0x7a): undefined reference to > `llvm::Type::getInt32Ty(llvm::LLVMContext&)'I'm pretty sure that the LLVMContext constructor is defined in libLLVMCore.a What is the output of `llvm-config --libs bitwriter`? Does it include -lLLVMCore? Ciao, Duncan. PS: There should be no need to use llvm-g++ rather than g++. If it makes a difference, then that is a bug.
On Sat, Jun 5, 2010 at 3:18 AM, Duncan Sands <baldrick at free.fr> wrote:> Hi Tom, > > I'm pretty sure that the LLVMContext constructor is defined in libLLVMCore.a > What is the output of `llvm-config --libs bitwriter`? Does it include > -lLLVMCore?Hi Duncan, e0082888 at e0082888-laptop:~$ local/bin/llvm-config --libs bitwriter -lLLVMBitWriter -lLLVMCore -lLLVMSupport -lLLVMSystem I verified it's pulling from the right library directory, because if I hide libLLVMCore.a from view and I get: e0082888 at e0082888-laptop:~/projects/llvm-hs/tools/ModuleMaker$ g++ `$HOME/local/bin/llvm-config --cppflags --cxxflags --ldflags --libs bitwriter` ModuleMaker.cpp /usr/bin/ld: cannot find -lLLVMCore collect2: ld returned 1 exit status And libLLVMCore.a contains at least something related to LLVMContext: e0082888 at e0082888-laptop:~/local/lib$ objdump -h libLLVMCore.a | grep LLVMContext LLVMContext.o: file format elf32-i386 313 .text._ZN4llvm15LLVMContextImplC1ERNS_11LLVMContextE 00001199 00000000 00000000 00007420 2**4 314 .text._ZN4llvm14object_creatorINS_11LLVMContextEEEPvv 0000003a 00000000 00000000 000085c0 2**4 319 .text._ZN4llvm15LLVMContextImplD1Ev 0000159d 00000000 00000000 00008900 2**4 320 .text._ZN4llvm14object_deleterINS_11LLVMContextEE4callEPv 0000003a 00000000 00000000 00009ea0 2**4 Here is the contents of my local library directory: e0082888 at e0082888-laptop:~$ ls -1 local/lib libCompilerDriver.a libEnhancedDisassembly.a libEnhancedDisassembly.so libllvm.a libLLVMAlphaAsmPrinter.a libLLVMAlphaCodeGen.a libLLVMAlphaInfo.a libllvm_analysis.a libLLVMAnalysis.a libLLVMArchive.a libLLVMARMAsmParser.a libLLVMARMAsmPrinter.a libLLVMARMCodeGen.a libLLVMARMInfo.a libLLVMAsmParser.a libLLVMAsmPrinter.a libllvm_bitreader.a libLLVMBitReader.a libllvm_bitwriter.a libLLVMBitWriter.a libLLVMBlackfinAsmPrinter.a libLLVMBlackfinCodeGen.a libLLVMBlackfinInfo.a libLLVMCBackend.a libLLVMCBackendInfo.a libLLVMCellSPUAsmPrinter.a libLLVMCellSPUCodeGen.a libLLVMCellSPUInfo.a libLLVMCodeGen.a libLLVMCore.a libLLVMCppBackend.a libLLVMCppBackendInfo.a libllvm_executionengine.a libLLVMExecutionEngine.a libLLVMHello.so libLLVMInstCombine.a libLLVMInstrumentation.a libLLVMInterpreter.a libLLVMipa.a libLLVMipo.a libLLVMJIT.a libLLVMLinker.a libLLVMMBlazeAsmPrinter.a libLLVMMBlazeCodeGen.a libLLVMMBlazeInfo.a libLLVMMC.a libLLVMMCParser.a libLLVMMipsAsmPrinter.a libLLVMMipsCodeGen.a libLLVMMipsInfo.a libLLVMMSIL.a libLLVMMSILInfo.a libLLVMMSP430AsmPrinter.a libLLVMMSP430CodeGen.a libLLVMMSP430Info.a libLLVMPIC16AsmPrinter.a libLLVMPIC16CodeGen.a libLLVMPIC16Info.a libLLVMpic16passes.a libLLVMPowerPCAsmPrinter.a libLLVMPowerPCCodeGen.a libLLVMPowerPCInfo.a libllvm_scalar_opts.a libLLVMScalarOpts.a libLLVMSelectionDAG.a libLLVMSparcAsmPrinter.a libLLVMSparcCodeGen.a libLLVMSparcInfo.a libLLVMSupport.a libLLVMSystem.a libLLVMSystemZAsmPrinter.a libLLVMSystemZCodeGen.a libLLVMSystemZInfo.a libllvm_target.a libLLVMTarget.a libLLVMTransformUtils.a libLLVMX86AsmParser.a libLLVMX86AsmPrinter.a libLLVMX86CodeGen.a libLLVMX86Disassembler.a libLLVMX86Info.a libLLVMXCoreAsmPrinter.a libLLVMXCoreCodeGen.a libLLVMXCoreInfo.a libLTO.a libLTO.so libplugin_llvmc_Base.a libplugin_llvmc_Clang.a libprofile_rt.so libUnitTestMain.a ocaml