getting-started-llvm-c-api
getting-started-llvm-c-api copied to clipboard
Error Build!
$ make
clang++ sum.o `llvm-config --cxxflags --ldflags --libs core executionengine jit interpreter analysis native bitwriter --system-libs` -o sum
llvm-config: unknown component name: jit
sum.o: In function `main':
/home/guest/Gits/Compiler/getting-started-llvm-c-api/sum.c:20: undefined reference to `LLVMModuleCreateWithName'
/home/guest/Gits/Compiler/getting-started-llvm-c-api/sum.c:22: undefined reference to `LLVMInt32Type'
/home/guest/Gits/Compiler/getting-started-llvm-c-api/sum.c:22: undefined reference to `LLVMInt32Type'
/home/guest/Gits/Compiler/getting-started-llvm-c-api/sum.c:23: undefined reference to `LLVMInt32Type'
/home/guest/Gits/Compiler/getting-started-llvm-c-api/sum.c:23: undefined reference to `LLVMFunctionType'
/home/guest/Gits/Compiler/getting-started-llvm-c-api/sum.c:24: undefined reference to `LLVMAddFunction'
/home/guest/Gits/Compiler/getting-started-llvm-c-api/sum.c:26: undefined reference to `LLVMAppendBasicBlock'
/home/guest/Gits/Compiler/getting-started-llvm-c-api/sum.c:28: undefined reference to `LLVMCreateBuilder'
/home/guest/Gits/Compiler/getting-started-llvm-c-api/sum.c:29: undefined reference to `LLVMPositionBuilderAtEnd'
...
how fix?
You should check out #2, which works with recent versions of LLVM.
i get:
sum.c:39: undefined reference to `LLVMLinkInJIT'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I get
clang -g llvm-config --cflags-c sum.c /bin/sh: 1: llvm-config: not found sum.c:39:5: warning: implicit declaration of function 'LLVMLinkInJIT' is invalid in C99 [-Wimplicit-function-declaration] LLVMLinkInJIT(); ^ 1 warning generated. clang++ sum.ollvm-config --cxxflags --ldflags --libs core executionengine jit interpreter analysis native bitwriter --
system-libs-o sum /bin/sh: 1: llvm-config: not found sum.o: In functionmain':
/root/programs/getting-started-llvm-c-api/sum.c:20: undefined reference to LLVMModuleCreateWithName' /root/programs/getting-started-llvm-c-api/sum.c:22: undefined reference to LLVMInt32Type'
/root/programs/getting-started-llvm-c-api/sum.c:22: undefined reference to LLVMInt32Type' /root/programs/getting-started-llvm-c-api/sum.c:23: undefined reference to LLVMInt32Type'
/root/programs/getting-started-llvm-c-api/sum.c:23: undefined reference to LLVMFunctionType' /root/programs/getting-started-llvm-c-api/sum.c:24: undefined reference to LLVMAddFunction'
/root/programs/getting-started-llvm-c-api/sum.c:26: undefined reference to LLVMAppendBasicBlock' /root/programs/getting-started-llvm-c-api/sum.c:28: undefined reference to LLVMCreateBuilder'
/root/programs/getting-started-llvm-c-api/sum.c:29: undefined reference to LLVMPositionBuilderAtEnd' /root/programs/getting-started-llvm-c-api/sum.c:30: undefined reference to LLVMGetParam'
/root/programs/getting-started-llvm-c-api/sum.c:30: undefined reference to LLVMGetParam' /root/programs/getting-started-llvm-c-api/sum.c:30: undefined reference to LLVMBuildAdd'
/root/programs/getting-started-llvm-c-api/sum.c:31: undefined reference to LLVMBuildRet' /root/programs/getting-started-llvm-c-api/sum.c:34: undefined reference to LLVMVerifyModule'
/root/programs/getting-started-llvm-c-api/sum.c:35: undefined reference to LLVMDisposeMessage' /root/programs/getting-started-llvm-c-api/sum.c:39: undefined reference to LLVMLinkInJIT'
/root/programs/getting-started-llvm-c-api/sum.c:41: undefined reference to LLVMCreateExecutionEngineForModule' /root/programs/getting-started-llvm-c-api/sum.c:47: undefined reference to LLVMDisposeMessage'
/root/programs/getting-started-llvm-c-api/sum.c:59: undefined reference to LLVMInt32Type' /root/programs/getting-started-llvm-c-api/sum.c:59: undefined reference to LLVMCreateGenericValueOfInt'
/root/programs/getting-started-llvm-c-api/sum.c:60: undefined reference to LLVMInt32Type' /root/programs/getting-started-llvm-c-api/sum.c:60: undefined reference to LLVMCreateGenericValueOfInt'
/root/programs/getting-started-llvm-c-api/sum.c:62: undefined reference to LLVMRunFunction' /root/programs/getting-started-llvm-c-api/sum.c:63: undefined reference to LLVMGenericValueToInt'
/root/programs/getting-started-llvm-c-api/sum.c:66: undefined reference to LLVMWriteBitcodeToFile' /root/programs/getting-started-llvm-c-api/sum.c:70: undefined reference to LLVMDisposeBuilder'
/root/programs/getting-started-llvm-c-api/sum.c:71: undefined reference to LLVMDisposeExecutionEngine' sum.o: In function LLVMInitializeNativeTarget':
/usr/include/llvm-c/Target.h:135: undefined reference to LLVMInitializeX86TargetInfo' /usr/include/llvm-c/Target.h:136: undefined reference to LLVMInitializeX86Target'
/usr/include/llvm-c/Target.h:137: undefined reference to LLVMInitializeX86TargetMC' clang: error: linker command failed with exit code 1 (use -v to see invocation) Makefile:12: recipe for target 'sum' failed make: *** [sum] Error 1