static jboolean libinit(JNIEnv *env, jobject obj, jint sdk) {
/*
#include <sys/system_properties.h>
int sdk;
char c[PROP_VALUE_MAX];
if(__system_property_get("ro.build.version.sdk",c) > 0) sscanf(c,"%d",&sdk);
else sdk = 8;
*/
__android_log_print(ANDROID_LOG_INFO,"liblossless","libinit: sdk=%d",sdk);
if(!libhandle) {
if(sdk < 8) libhandle = dlopen("/data/data/net.avs234/lib/libatrack8.so", RTLD_NOW);
else libhandle = dlopen("/data/data/net.avs234/lib/libatrack9.so", RTLD_NOW);
if(libhandle) {
libmedia_pause = (typeof(libmedia_pause)) dlsym(libhandle,"libmedia_pause");
libmedia_resume = (typeof(libmedia_resume)) dlsym(libhandle,"libmedia_resume");
libmedia_start = (typeof(libmedia_start)) dlsym(libhandle,"libmedia_start");
libmedia_stop = (typeof(libmedia_stop)) dlsym(libhandle,"libmedia_stop");
libmedia_write = (typeof(libmedia_write)) dlsym(libhandle,"libmedia_write");
libmediacb_start = (typeof(libmediacb_start)) dlsym(libhandle,"libmediacb_start");
libmediacb_stop = (typeof(libmediacb_stop)) dlsym(libhandle,"libmediacb_stop");
libmediacb_write = (typeof(libmediacb_write)) dlsym(libhandle,"libmediacb_write");
libmediacb_wait_done = (typeof(libmediacb_wait_done)) dlsym(libhandle,"libmediacb_wait_done");
}
}
__android_log_print(ANDROID_LOG_INFO,"liblossless","libinit: handle=%p",libhandle);
return libhandle != 0;
}
static jboolean libexit(JNIEnv *env, jobject obj) {
int ret = 0;
__android_log_print(ANDROID_LOG_INFO,"liblossless","libexit");
if(libhandle) {
ret = dlclose(libhandle) ? 0 : 1;
libhandle = 0;
}
return ret;
}
使用Cygwin編譯給我一個錯誤:爲什麼我在cygwin中遇到錯誤?
/cygdrive/C/androidndk4/apps/lossless/project/bin/ndk/local/armeabi/objs/lossles
S/main.o:在功能libexit': /cygdrive/C/androidndk4/apps/lossless/project/jni/main.c:247: undefined referenc e to
dlclose」 /cygdrive/C/androidndk4 /應用/無損/項目/斌/ NDK /本地/ armeabi/OBJ文件/ lossles S/main.o:在功能libinit': /cygdrive/C/androidndk4/apps/lossless/project/jni/main.c:226: undefined referenc e to
的dlopen ' /cygdrive/C/androidndk4/apps/lossless/project/jni/main.c:228:未定義和借鑑 E要dlsym' /cygdrive/C/androidndk4/apps/lossless/project/jni/main.c:229: undefined referenc e to
對dlsym' /cygdrive/C/androidndk4/apps/lossless/project/jni/main.c:230:undefined referenc E要dlsym' /cygdrive/C/androidndk4/apps/lossless/project/jni/main.c:231: undefined referenc e to
對dlsym ' /cygdrive/C/androidndk4/apps/lossless/project/jni/main.c:232:未定義和借鑑 E要dlsym' /cygdrive/C/androidndk4/apps/lossless/project/bin/ndk/local/armeabi/objs/lossles s/main.o:/cygdrive/C/androidndk4/apps/lossless/project/jni/main.c:233: more unde fined references to
對dlsym' 跟隨 /cygdrive/C/androidndk4 /應用/無損/項目/斌/ NDK /本地/ armeabi/OBJ文件/ lossles S/main.o:在功能libinit': /cygdrive/C/androidndk4/apps/lossless/project/jni/main.c:225: undefined referenc e to
的dlopen」 collect2:LD返回1個退出狀態 化妝:* [/ cygdrive/C/androidndk4 /應用/無損/ project/bin/ndk/local/armeabi/l iblossless.so]錯誤1
我是一個初學者,如何在頭文件中包含?非常感謝您的回答。 – user722641 2011-05-27 17:18:56
如果有人有一個想法......我等待 – user722641 2011-05-28 05:30:11
語法是:#include因此,在你的情況下,找到哪些頭文件這些dl *函數在,幷包括它們。 –
2011-05-31 15:28:38