Reputation: 325
I'm trying to compile fibonacci.cpp from llvm's examples to test llvm 3.8 (installed from repo) on my system (4.6.4-1-ARCH)
I get the following error. I dug around to see what's missing in llvm-config parameters but I wasn't lucky.
Below, I provide the command run and its output:
[drunk@teapot LLVMPlayBox]$ clang++ fibonacci.cpp `llvm-config --cxxflags --ldflags --libs --system-libs engine` -o fibonacci
warning: unknown warning option '-Wno-maybe-uninitialized'; did you mean '-Wno-uninitialized'? [-Wunknown-warning-option]
1 warning generated.
/tmp/fibonacci-34ba2b.o: In function `_GLOBAL__sub_I_fibonacci.cpp':
fibonacci.cpp:(.text.startup+0x1): undefined reference to `LLVMLinkInInterpreter'
clang-3.8: error: linker command failed with exit code 1 (use -v to see invocation)`
I also used -v to see more details but skipping most of it since it's lengthy:
....
1 warning generated.
"/usr/bin/ld" --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o fibonacci /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/6.1.1/../../../../lib64/crt1.o /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/6.1.1/../../../../lib64/crti.o /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/6.1.1/crtbegin.o -L/usr/lib -L/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/6.1.1 -L/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/6.1.1/../../../../lib64 -L/usr/bin/../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/6.1.1/../../.. -L/usr/bin/../lib -L/lib -L/usr/lib /tmp/fibonacci-5ea4ee.o -lLLVMX86Disassembler -lLLVMX86AsmParser -lLLVMX86CodeGen -lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMCodeGen -lLLVMScalarOpts -lLLVMInstCombine -lLLVMInstrumentation -lLLVMProfileData -lLLVMTransformUtils -lLLVMBitWriter -lLLVMX86Desc -lLLVMMCDisassembler -lLLVMX86Info -lLLVMX86AsmPrinter -lLLVMX86Utils -lLLVMMCJIT -lLLVMExecutionEngine -lLLVMTarget -lLLVMAnalysis -lLLVMRuntimeDyld -lLLVMObject -lLLVMMCParser -lLLVMBitReader -lLLVMMC -lLLVMCore -lLLVMSupport -lrt -ldl -lcurses -lpthread -lz -lm -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/6.1.1/crtend.o /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/6.1.1/../../../../lib64/crtn.o
/tmp/fibonacci-5ea4ee.o: In function `_GLOBAL__sub_I_fibonacci.cpp':
fibonacci.cpp:(.text.startup+0x1): undefined reference to `LLVMLinkInInterpreter'
clang-3.8: error: linker command failed with exit code 1 (use -v to see invocation)`
Edit: I tried as suggested but I got more errors now.
clang++ `llvm-config --cxxflags --ldflags --system-libs --libs engine interpreter` fibonacci.cpp -o fibonacci
warning: unknown warning option '-Wno-maybe-uninitialized'; did you mean '-Wno-uninitialized'? [-Wunknown-warning-option]
1 warning generated.
/usr/lib/libLLVMInterpreter.a(ExternalFunctions.cpp.o): In function `llvm::Interpreter::callExternalFunction(llvm::Function*, llvm::ArrayRef<llvm::GenericValue>)':
(.text._ZN4llvm11Interpreter20callExternalFunctionEPNS_8FunctionENS_8ArrayRefINS_12GenericValueEEE+0x333): undefined reference to `ffi_type_pointer'
/usr/lib/libLLVMInterpreter.a(ExternalFunctions.cpp.o): In function `llvm::Interpreter::callExternalFunction(llvm::Function*, llvm::ArrayRef<llvm::GenericValue>)':
(.text._ZN4llvm11Interpreter20callExternalFunctionEPNS_8FunctionENS_8ArrayRefINS_12GenericValueEEE+0x386): undefined reference to `ffi_type_sint64'
/usr/lib/libLLVMInterpreter.a(ExternalFunctions.cpp.o): In function `llvm::Interpreter::callExternalFunction(llvm::Function*, llvm::ArrayRef<llvm::GenericValue>)':
(.text._ZN4llvm11Interpreter20callExternalFunctionEPNS_8FunctionENS_8ArrayRefINS_12GenericValueEEE+0x397): undefined reference to `ffi_type_sint32'
/usr/lib/libLLVMInterpreter.a(ExternalFunctions.cpp.o): In function
.......
(.text._ZN4llvm11Interpreter20callExternalFunctionEPNS_8FunctionENS_8ArrayRefINS_12GenericValueEEE+0xd52): undefined reference to `ffi_type_sint64'
/usr/lib/libLLVMInterpreter.a(ExternalFunctions.cpp.o): In function `llvm::Interpreter::callExternalFunction(llvm::Function*, llvm::ArrayRef<llvm::GenericValue>)':
(.text._ZN4llvm11Interpreter20callExternalFunctionEPNS_8FunctionENS_8ArrayRefINS_12GenericValueEEE+0xd5e): undefined reference to `ffi_type_double'
/usr/lib/libLLVMInterpreter.a(ExternalFunctions.cpp.o): In function `llvm::Interpreter::callExternalFunction(llvm::Function*, llvm::ArrayRef<llvm::GenericValue>)':
(.text._ZN4llvm11Interpreter20callExternalFunctionEPNS_8FunctionENS_8ArrayRefINS_12GenericValueEEE+0xd6a): undefined reference to `ffi_type_sint32'
/usr/lib/libLLVMInterpreter.a(ExternalFunctions.cpp.o): In function `llvm::Interpreter::callExternalFunction(llvm::Function*, llvm::ArrayRef<llvm::GenericValue>)':
(.text._ZN4llvm11Interpreter20callExternalFunctionEPNS_8FunctionENS_8ArrayRefINS_12GenericValueEEE+0xd7b): undefined reference to `ffi_type_sint8'
/usr/lib/libLLVMInterpreter.a(ExternalFunctions.cpp.o): In function `llvm::Interpreter::callExternalFunction(llvm::Function*, llvm::ArrayRef<llvm::GenericValue>)':
(.text._ZN4llvm11Interpreter20callExternalFunctionEPNS_8FunctionENS_8ArrayRefINS_12GenericValueEEE+0xd87): undefined reference to `ffi_type_sint16'
/usr/lib/libLLVMInterpreter.a(ExternalFunctions.cpp.o): In function `llvm::Interpreter::callExternalFunction(llvm::Function*, llvm::ArrayRef<llvm::GenericValue>)':
(.text._ZN4llvm11Interpreter20callExternalFunctionEPNS_8FunctionENS_8ArrayRefINS_12GenericValueEEE+0xd93): undefined reference to `ffi_type_float'
/usr/lib/libLLVMInterpreter.a(ExternalFunctions.cpp.o): In function
.....
(.text._ZN4llvm11Interpreter20callExternalFunctionEPNS_8FunctionENS_8ArrayRefINS_12GenericValueEEE+0x1368): undefined reference to `ffi_type_float'
/usr/lib/libLLVMInterpreter.a(ExternalFunctions.cpp.o): In function `llvm::Interpreter::callExternalFunction(llvm::Function*, llvm::ArrayRef<llvm::GenericValue>)':
(.text._ZN4llvm11Interpreter20callExternalFunctionEPNS_8FunctionENS_8ArrayRefINS_12GenericValueEEE+0x1374): undefined reference to `ffi_type_void'
clang-3.8: error: linker command failed with exit code 1 (use -v to see invocation)
Edit #2: I added -lffi as suggested and it worked. So the command issued is:
clang++ fibonacci.cpp `llvm-config --cxxflags --ldflags --system-libs --libs engine interpreter ` -lffi -o fibonacci
Upvotes: 1
Views: 1579
Reputation: 4117
LLVMLinkInInterpreter
is part of libLLVMInterpreter, which is not included in your llvm-config
command. To fix the problem you simply need to extend your build script as following:
llvm-config --cxxflags --ldflags --system-libs --libs engine interpreter
Notice --libs interpreter
at the end.
Upvotes: 2