我试图从llvm的例子中编译fibonacci.cpp来测试我的系统上的llvm 3.8(从repo安装)(4.6.4-1-ARCH)
我收到以下错误。我挖了一下,看看llvm-config参数中缺少什么,但我不幸运。
下面,我提供命令运行及其输出:
[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)`
我还使用-v查看更多详细信息但跳过大部分细节,因为它很冗长:
....
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)`
编辑: 我按照建议尝试但现在我遇到了更多错误。
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)
编辑#2: 我按照建议添加了-lffi并且它有效。所以发出的命令是:
clang++ fibonacci.cpp `llvm-config --cxxflags --ldflags --system-libs --libs engine interpreter ` -lffi -o fibonacci
答案 0 :(得分:2)
Search: <input type="text" name="term" /><br />
是libLLVMInterpreter的一部分,它不包含在LLVMLinkInInterpreter
命令中。要解决此问题,您只需按以下步骤扩展构建脚本:
llvm-config
最后注意llvm-config --cxxflags --ldflags --system-libs --libs engine interpreter
。