[LLVMdev] call a extern C function
samuraileumas at yahoo.com
Thu Jun 3 12:17:23 PDT 2010
You have to make a C wrapper for any C++ code due to "name mangling". This usually looks something like:
extern "C" int mysum(int a, int b)
And then you declare it in the bitcode like this:
declare external i32 mysum(i32, i32)
Then you link both the wrapper and the C++ code in like you would any other linker library, noting the linking order is significant.
Note: I haven't tested this I may have mistyped something in the commands since I'm typing from memory.
>From: Fabio Kaminski <fabiokaminski at gmail.com>
>To: llvmdev at cs.uiuc.edu
>Sent: Thu, June 3, 2010 2:07:29 PM
>Subject: [LLVMdev] call a extern C function
>How can i interface llvm bitcode with a existent so library...
>like when you use C prebuilt cos() or sin() ... suppose that i create a sum() in c/c++ compile a .so lib with it
>and call it from "the bitcode" program... how can i do this?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the llvm-dev