mingw, llvm 2.6 (buid with llvm-gcc)
Example source code:
http://npcontemplation.blogspot.com/2008/06/secret-of-llvm-c-bindings.html
I change
LLVMCreateJITCompiler(&engine, provider, &error);
to
LLVMCreateJITCompiler(&engine, provider, 3, &error);
$ llvm-gcc `llvm-config --cflags` -c fac.c
$ g++ `llvm-config --libs --cflags --ldflags core analysis
executionengine jit interpreter native backend engine` fac.o -o fac
fac.o: In function `main':
c:\Work\llvm//fac.c:20: undefined reference to `LLVMModuleCreateWithName'
c:\Work\llvm//fac.c:21: undefined reference to `LLVMInt32Type'
c:\Work\llvm//fac.c:22: undefined reference to `LLVMInt32Type'
c:\Work\llvm//fac.c:22: undefined reference to `LLVMFunctionType'
c:\Work\llvm//fac.c:22: undefined reference to `LLVMAddFunction'
c:\Work\llvm//fac.c:23: undefined reference to `LLVMSetFunctionCallConv'
c:\Work\llvm//fac.c:24: undefined reference to `LLVMGetParam'
c:\Work\llvm//fac.c:26: undefined reference to `LLVMAppendBasicBlock'
c:\Work\llvm//fac.c:27: undefined reference to `LLVMAppendBasicBlock'
c:\Work\llvm//fac.c:28: undefined reference to `LLVMAppendBasicBlock'
c:\Work\llvm//fac.c:29: undefined reference to `LLVMAppendBasicBlock'
c:\Work\llvm//fac.c:30: undefined reference to `LLVMCreateBuilder'
c:\Work\llvm//fac.c:32: undefined reference to `LLVMPositionBuilderAtEnd'
c:\Work\llvm//fac.c:33: undefined reference to `LLVMInt32Type'
c:\Work\llvm//fac.c:33: undefined reference to `LLVMConstInt'
c:\Work\llvm//fac.c:33: undefined reference to `LLVMBuildICmp'
c:\Work\llvm//fac.c:34: undefined reference to `LLVMBuildCondBr'
c:\Work\llvm//fac.c:36: undefined reference to `LLVMPositionBuilderAtEnd'
c:\Work\llvm//fac.c:37: undefined reference to `LLVMInt32Type'
c:\Work\llvm//fac.c:37: undefined reference to `LLVMConstInt'
c:\Work\llvm//fac.c:38: undefined reference to `LLVMBuildBr'
c:\Work\llvm//fac.c:40: undefined reference to `LLVMPositionBuilderAtEnd'
c:\Work\llvm//fac.c:41: undefined reference to `LLVMInt32Type'
c:\Work\llvm//fac.c:41: undefined reference to `LLVMConstInt'
c:\Work\llvm//fac.c:41: undefined reference to `LLVMBuildSub'
c:\Work\llvm//fac.c:43: undefined reference to `LLVMBuildCall'
c:\Work\llvm//fac.c:44: undefined reference to `LLVMBuildMul'
c:\Work\llvm//fac.c:45: undefined reference to `LLVMBuildBr'
c:\Work\llvm//fac.c:47: undefined reference to `LLVMPositionBuilderAtEnd'
c:\Work\llvm//fac.c:48: undefined reference to `LLVMInt32Type'
c:\Work\llvm//fac.c:48: undefined reference to `LLVMBuildPhi'
c:\Work\llvm//fac.c:51: undefined reference to `LLVMAddIncoming'
c:\Work\llvm//fac.c:52: undefined reference to `LLVMBuildRet'
c:\Work\llvm//fac.c:54: undefined reference to `LLVMVerifyModule'
c:\Work\llvm//fac.c:55: undefined reference to `LLVMDisposeMessage'
c:\Work\llvm//fac.c:59: undefined reference to
`LLVMCreateModuleProviderForExistingModule'
c:\Work\llvm//fac.c:61: undefined reference to `LLVMCreateJITCompiler'
c:\Work\llvm//fac.c:64: undefined reference to `LLVMDisposeMessage'
c:\Work\llvm//fac.c:68: undefined reference to `LLVMCreatePassManager'
c:\Work\llvm//fac.c:69: undefined reference to
`LLVMGetExecutionEngineTargetData'
c:\Work\llvm//fac.c:69: undefined reference to `LLVMAddTargetData'
c:\Work\llvm//fac.c:70: undefined reference to
`LLVMAddConstantPropagationPass'
c:\Work\llvm//fac.c:71: undefined reference to
`LLVMAddInstructionCombiningPass'
c:\Work\llvm//fac.c:72: undefined reference to
`LLVMAddPromoteMemoryToRegisterPass'
c:\Work\llvm//fac.c:74: undefined reference to `LLVMAddGVNPass'
c:\Work\llvm//fac.c:75: undefined reference to
`LLVMAddCFGSimplificationPass'
c:\Work\llvm//fac.c:76: undefined reference to `LLVMRunPassManager'
c:\Work\llvm//fac.c:77: undefined reference to `LLVMDumpModule'
c:\Work\llvm//fac.c:79: undefined reference to `LLVMInt32Type'
c:\Work\llvm//fac.c:79: undefined reference to `LLVMCreateGenericValueOfInt'
c:\Work\llvm//fac.c:80: undefined reference to `LLVMRunFunction'
c:\Work\llvm//fac.c:83: undefined reference to `LLVMGenericValueToInt'
c:\Work\llvm//fac.c:85: undefined reference to `LLVMDisposePassManager'
c:\Work\llvm//fac.c:86: undefined reference to `LLVMDisposeBuilder'
c:\Work\llvm//fac.c:87: undefined reference to `LLVMDisposeExecutionEngine'
collect2: ld returned 1 exit status
$ llvm-config --libs --cflags --ldflags core analysis executionengine
jit interpreter native backend engine
-I/mingw/include -D_DEBUG -D_GNU_SOURCE -D__STDC_LIMIT_MACROS
-D__STDC_CONSTANT_MACROS -O2 -fomit-frame-pointer
-L/mingw/lib -lffi -lpsapi -limagehlp -lm
-lLLVMX86AsmParser -lLLVMX86AsmPrinter -lLLVMX86CodeGen
-lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMX86Info -lLLVMInterpreter
-lLLVMJIT -lLLVMCodeGen -lLLVMScalarOpts -lLLVMTransformUtils -lLLVMipa
-lLLVMExecutionEngine -lLLVMAnalysis -lLLVMTarget -lLLVMMC -lLLVMCore
-lLLVMSupport -lLLVMSystem
What is wrong? All undefined names from libLLVMCore.a
--
WBR, Yaroslav Kavenchuk