android ndk prebuild,Android NDK prebuild shared library usage

I have precompiled shared library (.so), named libxxx.so.3.3. I don't know why the name after compilation was "libxxx.so.3.3". I'd like to use it in my Android app via JNI. For this i've created ndk module xxx_jni:

Android.mk:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE := xxx

LOCAL_SRC_FILES := xxx.so

include $(PREBUILT_SHARED_LIBRARY)

include $(CLEAR_VARS)

LOCAL_MODULE := xxx_jni

LOCAL_SRC_FILES := xxx_wrapper.c

LOCAL_SHARED_LIBRARIES := xxx

LOCAL_C_INCLUDES := /softdev/xxx/host/include/

include $(BUILD_SHARED_LIBRARY)

I had to rename ".so.3.3" to ".so" as ndk-build failed to compile libxxx_jni.so:

Android NDK: ERROR:/Users/user/Documents/dev/src/xxx_jni/jni/Android.xxx: LOCAL_SRC_FILES should point to a file ending with ".so"

Android NDK: The following file is unsupported: libxxx.so.3.3

My wrapper class (for JNI):

#include "xxx_wrapper.h"

#include // include "xxx" library header

#ifndef _Included_name_antonsmirnov_android_xxx_wrapper

#define _Included_name_antonsmirnov_android_xxx_wrapper

#ifdef __cplusplus

extern "C" {

#endif

/*

* Class: name_antonsmirnov_android_xxx_wrapper

* Method: exec_test

* Signature: (Ljava/lang/String;)I

*/

JNIEXPORT jint JNICALL Java_name_antonsmirnov_android_xxx_1wrapper_exec_1test(JNIEnv *, jobject, jstring)

{

// using method from "xxx" library

xxx_method();

return 7;

}

So after ndk compilation (ndk-build) i have 2 stripped files in "libs/armeabi" folder: libxxx.so and libxxx_jni.so.

Then i try to load libraries in runtime in wrapper class:

public class xxx_wrapper {

static {

System.loadLibrary("xxx");

System.loadLibrary("xxx_jni"); // error here!

}

error:

at dalvik.system.NativeStart.main(Native Method)

Caused by: java.lang.UnsatisfiedLinkError: Cannot load library: link_image[1891]: 167 could not load needed library 'libxxx.so.3.3' for 'libxxx_jni.so' (load_library[1093]: Library 'libxxx.so.3.3' not found)

So i'm in stuck what i've missed.. I've tried to leave ".so.3.3" extension and symlink ".so" -> ".so.3.3" but the same result. As far as i understand the problem is that xxx_wrapper lib still wants ".so.3.3" library loaded, but it's ".so".

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值