On Sat, Mar 5, 2011 at 12:41 PM, Amir Mofakhar <pangan at gmail.com>
wrote:> Hi there,
>
> It will be appreciated if you help me :
>
> I need to call an external function in LLVM bitcode but don't know how
:
>
> ;ModuleID = 'm1'
> define i32 @main() {
> entry:
> %tmp0 = call i32 @MyOwnFunction()
> ret i32 0
> }
> declare i32 @MyOwnFunction()
>
> I use below codes to run it
>
> $ llvm-as -f m1 -o m1.bc
> $ lli 1.bc
>
> (before it I have compiled MyOwnFunction module)
>
> when I run this program i receive this error :
> LLVM ERROR: Program used external function 'MyOwnFunction' which
could not
> be resolved!
>
> I know it can not find this external function but I don't know how to
define
> this function in another module and use it in my modules. i used below code
> for the other module :
>
> ;ModuleID = 'MyOwnFunction'
> define i32 @MyOwnFunction() {
> entry:
> ret i32 55
> }
>
> should i use any especial switch to compile or what should i chane in my
> codes? I received error by below command also :
>
> $ lli -load MyOwnFunction.bc m1.bc
Try something like the following?
llvm-link MyOwnFunction.bc m1.bc -o - | lli
-Eli