Issue
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := slabhidtouart
LOCAL_SRC_FILES := libslabhidtouart.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := TestJNI
### Add all source file names to be included in lib separated by a whitespace
LOCAL_C_INCLUDES := $(LOCAL_PATH)
LOCAL_SRC_FILES := TestJNI.cpp
LOCAL_SHARED_LIBRARIES := slabhidtouart
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/jni
include $(BUILD_SHARED_LIBRARY)
compiling with ndk build giving error
testjni1//obj/local/armebai/libslabhidtouart.so: incompatible target
can anyone tell me where i am going wrong
Edit: using readelf -d i got this
Dynamic section at offset 0x1fd90 contains 28 entries:
Tag Type Name/Value
0x0000000000000001 (NEEDED) Shared library: [libusb-1.0.so.0]
0x0000000000000001 (NEEDED) Shared library: [libstdc++.so.6]
0x0000000000000001 (NEEDED) Shared library: [libgcc_s.so.1]
0x0000000000000001 (NEEDED) Shared library: [libc.so.6]
0x000000000000000e (SONAME) Library soname: [libslabhidtouart.so.1]
some libraries are marked as needed what that means.
actually i am new to this kind of projects so i was confused with what i need and what i have to do next. now i got some things like i was using a library which is built for another cpu(x86_64) and i need library for ARM, thanks to you guys, you make me clear
Solution
This reference:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := slabhidtouart
LOCAL_SRC_FILES := libslabhidtouart.so
include $(PREBUILT_SHARED_LIBRARY)
means that you want to use libslabhidtouart.so
when compiling your module. But .so files are binaries that are compatible only with one specific cpu-architecture/OS.
The error you're getting means that ndk-build is trying to use your .so file while compiling your module for an incompatible target.
Android supports several cpu architectures (armeabi, armeabi-v7a, arm64-v8a, x86, x86_64, mips, mips64). You can choose which one you want to support using the APP_ABI variable from Application.mk. If you set it to all
, ndk-build will try to use this .so file you're referencing for each of these architectures, but this cannot work.
Your .so file must have been compiled for Android platforms, and you need to have a different version of it for each architecture you're supporting. You can give a dynamic reference to the right .so file, such as LOCAL_SRC_FILES := $(TARGET_ARCH_ABI)/libslabhidtouart.so
so it looks for your .so file under armeabi-v7a folder when compiling for armeabi-v7a, under x86 for x86, etc.
Of course you need to provide these .so files. If you can't get .so files for all the supported architectures, you'll have to restrict your APP_ABI
to the architectures of the .so file you have. You can determine the architecture your .so file has been compiled for using readelf.
edit: your latest comment precise that your .so file has been compiled for x86, but I also suspect it's for standard Linux, not Android. You can use readelf -d to check your lib dependencies.
Answered By - ph0b
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.