[LLVMdev] Linking with C Library
mcheva at cs.mcgill.ca
Sun Apr 4 08:41:10 PDT 2010
I'm coding a JIT compiler for C source in OCaml, using LLVM. I'm pretty much
done with the LLVM code generation. The problem is that I can't seem to call
C library functions. I was told that all I needed to do to be able to link
with libc functions was to declare them in my module and give them external
linkage, but this does not seem to work. Please note that this is a JIT
compiler. I am not generating a binary, but running the code generated in
memory. It should be possible to dynamically link with the libc functions
because the ocaml executable is linked with them.
The three libc functions I declared appear in my module dump as such:
declare i8* @malloc(i32)
declare void @free(i8*)
declare i32 @puts(i8*)
However, when trying to run my program, I get the following:
LLVM ERROR: Tried to execute an unknown external function: i32 (i8*)* puts
I'm not quite sure how to go about this. Any help would be appreciated.
View this message in context: http://old.nabble.com/Linking-with-C-Library-tp28133460p28133460.html
Sent from the LLVM - Dev mailing list archive at Nabble.com.
More information about the llvm-dev