WEB开发网
开发学院手机开发Android 开发 Android NDK动态库的调用 阅读

Android NDK动态库的调用

 2010-09-16 23:50:00 来源:WEB开发网   
核心提示:thiz){//getinformation(); ??thr .so file will load to the sdcard with the folder data/data/com.example.test/lib/void* filehandle = dlopen("/data/data/com.e
thiz)

{

//getinformation(); ??thr .so file will load to the sdcard with the folder data/data/com.example.test/lib/

void* filehandle = dlopen("/data/data/com.example.test/lib/libtutorial.so", RTLD_LAZY );

int ll = -1;

if(filehandle)

{

LOGI("open so success!");

int( * getinformation ) ();

getinformation = dlsym(filehandle, "getinformation");

if( getinformation )

{

LOGI("call function getinformation OK!");

ll = getinformation();

}

else

{

ll = -3;

LOGE("call function getinformation! ERROR!");

}

LOGI("return value=%d",ll);

dlclose(filehandle);

filehandle=0;

}

else

{

ll = -2;

LOGE("open so ERROR!");

}

return ll;

}

tutorial01.c

#include

#include "tutorial02.h"

int getinformation()

{

int c = getinformation2(191,81);

return c;

}

tutorial02.c

#include

#include "tutorial02.h"

int getinformation2(int i,int j)

{

return (i+j);

}

tutorial02.h

int getinformation2(int,int);

C: 编译:

进入工程目录,执行 $NDK/ndk-build

输出结果:

$NDK/ndk-build

/cygdrive/e/cygwin/android-ndk-r4

Compile thumb : test <= /cygdrive/e/cygwin/android-ndk-r4/samples/testappso/jni/test01.c

SharedLibrary : libtest.so

Install : libtest.so =>

上一页  1 2 3 4 5 6 7 8  下一页

Tags:Android NDK 动态

编辑录入:coldstar [复制链接] [打 印]
赞助商链接