you should use ndk-buildndk-build instead directly arm-linux-androideabi-gccarm-linux-androideabi-gcc
in Android.mkAndroid.mk of library type next options: LOCAL_LDFLAGS += -Wl,--export-dynamicLOCAL_LDFLAGS += -Wl,--export-dynamic
if dlerror()dlerror() returns error it doesn't mean that dlsym()dlsym() failed. Check if dlsym() realledlsym() really returns nullNULL. Because it may return a valid address but dlerror()dlerror() may return error "Symbol not found" at the same time %)) I had this stupid mistake!!! See code.
You do not need call System.LoadLibrary(your_lib.so)System.LoadLibrary(your_lib.so). Only dlopen(your_lib.so)dlopen("your_lib.so") from native code with RTLD_NOWRTLD_NOW or RTLD_LAZYRTLD_LAZY no matter!
Be sure that your_lib.soyour_lib.so is sutiatedsituated in /data/data/app_name/libs/data/data/app_name/libs
func = (int (*)(int, int)) dlsym( dl_handle, "calculate" );
error = (char *) dlerror();
if (error != NULL) { //replace it with if ((func == NULL)&& (error != NULL))
__android_log_print(ANDROID_LOG_INFO,"nativeCode",error);
return -3;
}
func = (int (*)(int, int)) dlsym( dl_handle, "calculate" );
error = (char *) dlerror();
if (error != NULL) { //replace it with if ((func == NULL)&& (error != NULL))
__android_log_print(ANDROID_LOG_INFO,"nativeCode",error);
return -3;
}
That's all :)
Some important rules:
you should use ndk-build instead directly arm-linux-androideabi-gcc
in Android.mk of library type next options: LOCAL_LDFLAGS += -Wl,--export-dynamic
if dlerror() returns error it doesn't mean that dlsym() failed. Check if dlsym() realle returns null. Because it may return a valid address but dlerror() may return error "Symbol not found" at the same time %)) I had this stupid mistake!!! See code.
You do not need call System.LoadLibrary(your_lib.so). Only dlopen(your_lib.so) from native code with RTLD_NOW or RTLD_LAZY no matter!
Be sure that your_lib.so is sutiated in /data/data/app_name/libs
func = (int (*)(int, int)) dlsym( dl_handle, "calculate" );
error = (char *) dlerror();
if (error != NULL) { //replace it with if ((func == NULL)&& (error != NULL))
__android_log_print(ANDROID_LOG_INFO,"nativeCode",error);
return -3;
}
That's all :)
Some important rules:
you should use ndk-build instead directly arm-linux-androideabi-gcc
in Android.mk of library type next options: LOCAL_LDFLAGS += -Wl,--export-dynamic
if dlerror() returns error it doesn't mean that dlsym() failed. Check if dlsym() really returns NULL. Because it may return a valid address but dlerror() may return error "Symbol not found" at the same time %)) I had this stupid mistake!!! See code.
You do not need call System.LoadLibrary(your_lib.so). Only dlopen("your_lib.so") from native code with RTLD_NOW or RTLD_LAZY no matter!
Be sure that your_lib.so is situated in /data/data/app_name/libs
func = (int (*)(int, int)) dlsym( dl_handle, "calculate" );
error = (char *) dlerror();
if (error != NULL) { //replace it with if ((func == NULL)&& (error != NULL))
__android_log_print(ANDROID_LOG_INFO,"nativeCode",error);
return -3;
}
you should use ndk-build instead directly arm-linux-androideabi-gcc
in Android.mk of library type next options: LOCAL_LDFLAGS += -Wl,--export-dynamicLOCAL_LDFLAGS += -Wl,--export-dynamic
if dlerror() returns error it doesn't mean that dlsym() failed. Check if dlsym() realle returns null. Because it may returnsreturn a valid address but dlerror()returnsmay return error "Symbol not found)found" at the same time %)) I had this stupid mistake!!! See code.
You do not need call System.LoadLibrary(your_lib.so). Only dlopen(your_lib.so) from native code with RTLD_NOW or RTLD_LAZY no matter!
Be sure that your_lib.so is sutiated in /data/data/app_name/libs
func = (int (*)(int, int)) dlsym( dl_handle, "calculate" );
error = (char *) dlerror();
if if (error != NULL) {//replace it with if ((func == NULL)&& (error{!= NULL))//replace it with if ((func == NULL)&& (error != NULL))
__android_log_print(ANDROID_LOG_INFO,"nativeCode",error);
return -3;
}
You do not need call System.LoadLibrary(your_lib.so). Only dlopen(your_lib.so) from native code with RTLD_NOW or RTLD_LAZY no matter!
Be sure that your_lib.so is sutiated in /data/data/<app_name>/libs
That's all :)
Some rules:
you should use ndk-build instead directly arm-linux-androideabi-gcc
in Android.mk of library type next options: LOCAL_LDFLAGS += -Wl,--export-dynamic
if dlerror() returns error it doesn't mean that dlsym() failed. Check if dlsym() realle returns null. Because it may returns a valid address but dlerror()returns error "Symbol not found) %)) I had this stupid mistake!!! See code.
func = (int (*)(int, int)) dlsym( dl_handle, "calculate" );
error = (char *) dlerror();
if (error != NULL) {//replace it with if ((func == NULL)&& (error!= NULL))
__android_log_print(ANDROID_LOG_INFO,"nativeCode",error);
return -3;
}
You do not need call System.LoadLibrary(your_lib.so). Only dlopen(your_lib.so) from native code with RTLD_NOW or RTLD_LAZY no matter!
Be sure that your_lib.so is sutiated in /data/data/<app_name>/libs
That's all :)
Some important rules:
you should use ndk-build instead directly arm-linux-androideabi-gcc
in Android.mk of library type next options: LOCAL_LDFLAGS += -Wl,--export-dynamic
if dlerror() returns error it doesn't mean that dlsym() failed. Check if dlsym() realle returns null. Because it may return a valid address but dlerror()may return error "Symbol not found" at the same time %)) I had this stupid mistake!!! See code.
You do not need call System.LoadLibrary(your_lib.so). Only dlopen(your_lib.so) from native code with RTLD_NOW or RTLD_LAZY no matter!
Be sure that your_lib.so is sutiated in /data/data/app_name/libs
func = (int (*)(int, int)) dlsym( dl_handle, "calculate" );
error = (char *) dlerror();
if (error != NULL){//replace it with if ((func == NULL)&& (error != NULL))
__android_log_print(ANDROID_LOG_INFO,"nativeCode",error);
return -3;
}
you should use ndk-build instead directly arm-linux-androideabi-gcc
in Android.mk of library type next options: LOCAL_LDFLAGS += -Wl,--export-dynamic
if dlerror() returns error it doesn't mean that dlsym() failed. Check if dlsym() realle returns null. Because it may returns a valid address but dlerror() returns error "Symbol not found) %)) I had this stupid mistake!!! See code.
func = (int (*)(int, int)) dlsym( dl_handle, "calculate" );
error = (char *) dlerror();
if (error != NULL) { //replace it with if ((func == NULL)&& (error != NULL))
__android_log_print(ANDROID_LOG_INFO,"nativeCode",error);
return -3;
}
You do not need call System.LoadLibrary(your_lib.so). Only dlopen(your_lib.so) from native code with RTLD_NOW or RTLD_LAZY no matter!
Be sure that your_lib.so is sutiated in /data/data/<app_name>/libs
That's all :)
default
Your privacy
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.