找不到入口点,Android .so文件 [英] Entry point not found, Android .so file

查看:100
本文介绍了找不到入口点,Android .so文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将一些已编译的C代码合并到Android应用程序中.我已经能够使用NDK来构建源代码,并且它同时生成了.so(7kB)和.a(将近2MB).

I am trying to incorporate some compiled C code into an Android app. I've been able to use the NDK to build the source and it has produced both a .so (7kB) and a .a (nearly 2MB).

我正在使用Xamarin,所有说明都说要在项目中包含.so.我已经完成了,应用程序加载了库.但是,它将引发EntryPointNotFoundException异常.这并不令我感到惊讶,因为.so除了RTL支持功能外不包含任何内容.实际代码在.a中.

I'm using Xamarin and all the instructions say to include the .so in the project. I've done that and the application loads the library. However it throws an EntryPointNotFoundException exception. This doesn't surprise me because the .so contains nothing except RTL support functions. The actual code is in the .a.

所以我有两个问题: 1.如何将.a链接到我的Android库中? 或者 2.如何让NDK将所有内容打包到一个.so中?

So I have two questions: 1. How can I link the .a into my Android library? or 2. How can I get NDK to package everything into a single .so?

For what it's worth here is the .mk file:

ROOT := $(call my-dir)

# Build libopus
LOCAL_PATH          := ../opus-1.2.1/opus-1.2.1
include $(CLEAR_VARS)
#include the .mk files
include $(LOCAL_PATH)/celt_sources.mk
include $(LOCAL_PATH)/silk_sources.mk
include $(LOCAL_PATH)/opus_sources.mk

LOCAL_MODULE        := opus

#fixed point sources
SILK_SOURCES += $(SILK_SOURCES_FIXED)

#floating point sources - this throws badly!
#SILK_SOURCES += $(SILK_SOURCES_FLOAT)

#ARM build
CELT_SOURCES += $(CELT_SOURCES_ARM)
SILK_SOURCES += $(SILK_SOURCES_ARM)
LOCAL_SRC_FILES     := \
$(CELT_SOURCES) $(SILK_SOURCES) $(OPUS_SOURCES)

LOCAL_LDLIBS        := -lm -llog


LOCAL_C_INCLUDES    := \
$(LOCAL_PATH)/include \
$(LOCAL_PATH)/silk \
$(LOCAL_PATH)/silk/float \
$(LOCAL_PATH)/celt

LOCAL_CFLAGS        := -DNULL=0 -DSOCKLEN_T=socklen_t -DLOCALE_NOT_USED -D_LARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64
#LOCAL_CFLAGS        += -Drestrict='' -D__EMX__ -DOPUS_BUILD -DFIXED_POINT=1 -DDISABLE_FLOAT_API -DUSE_ALLOCA -DHAVE_LRINT -DHAVE_LRINTF -O3 -fno-math-errno
LOCAL_CFLAGS        += -Drestrict='' -D__EMX__ -DOPUS_BUILD -DUSE_ALLOCA -DHAVE_LRINT -DHAVE_LRINTF -O3 -fno-math-errno
LOCAL_CPPFLAGS      := -DBSD=1
LOCAL_CPPFLAGS      += -ffast-math -O3 -funroll-loops

#include $(BUILD_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE    := opus-share
#LOCAL_SRC_FILES := libopus.a
LOCAL_STATIC_LIBRARIES := opus
include $(BUILD_SHARED_LIBRARY)

谢谢.

推荐答案

我可以确认更改为LOCAL_WHOLE_STATIC_LIBRARIES确实是解决方案.同样,原始mk试图同时成为固定点和浮点.因此,所有这些的最终解决方案:

I can confirm that changing to LOCAL_WHOLE_STATIC_LIBRARIES was indeed the solution. Also the original mk is attempting to be both fixed and floating point. So the final fix to all this:

# This .mk has to be in a folder called jni. Because :(
ROOT := $(call my-dir)

# Build libopus.a (static library)
LOCAL_PATH          := ../opus-1.2.1/opus-1.2.1
include $(CLEAR_VARS)
#include the .mk files
include $(LOCAL_PATH)/celt_sources.mk
include $(LOCAL_PATH)/silk_sources.mk
include $(LOCAL_PATH)/opus_sources.mk

LOCAL_MODULE        := opus

#fixed point sources
SILK_SOURCES += $(SILK_SOURCES_FIXED)

#floating point sources - this throws badly!
#SILK_SOURCES += $(SILK_SOURCES_FLOAT)

#ARM build
CELT_SOURCES += $(CELT_SOURCES_ARM)
SILK_SOURCES += $(SILK_SOURCES_ARM)
LOCAL_SRC_FILES     := \
$(CELT_SOURCES) $(SILK_SOURCES) $(OPUS_SOURCES)

LOCAL_LDLIBS        := -lm -llog

LOCAL_C_INCLUDES    := \
$(LOCAL_PATH)/include \
$(LOCAL_PATH)/silk \
$(LOCAL_PATH)/silk/fixed \
$(LOCAL_PATH)/celt

LOCAL_CFLAGS        := -DNULL=0 -DSOCKLEN_T=socklen_t -DLOCALE_NOT_USED -D_LARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64
LOCAL_CFLAGS        += -Drestrict='' -D__EMX__ -DOPUS_BUILD -DFIXED_POINT=1 -DDISABLE_FLOAT_API -DUSE_ALLOCA -DHAVE_LRINT -DHAVE_LRINTF -O3 -fno-math-errno
#LOCAL_CFLAGS        += -Drestrict='' -D__EMX__ -DOPUS_BUILD -DUSE_ALLOCA -DHAVE_LRINT -DHAVE_LRINTF -O3 -fno-math-errno
LOCAL_CPPFLAGS      := -DBSD=1
LOCAL_CPPFLAGS      += -ffast-math -O3 -funroll-loops

include $(BUILD_STATIC_LIBRARY)

# Now create a dynamic library that contains the static library
include $(CLEAR_VARS)
LOCAL_MODULE    := opus-share
#LOCAL_SRC_FILES := opus
LOCAL_WHOLE_STATIC_LIBRARIES := opus
include $(BUILD_SHARED_LIBRARY)

这是使用Windows NDK构建的,我不得不将该文件(称为Android.mk)放入名为``JNI''的目录中,可能有一些技巧可以避免涉及环境变量,但是我放弃了尝试它.将其与 opus 1.2.1源代码以及平台特定的mk文件,如下所示:

This was built using the Windows NDK and I had to put that file (called Android.mk) into a directory called 'JNI'.There may be some trick to avoid doing that involving environment variables but I gave up trying to fight it. Combine that with opus 1.2.1 source code and platform specific mk files like this:

APP_ABI := arm64-v8a
APP_PLATFORM := android-19
APP_STL := c++_static
APP_BUILD_SCRIPT := Android.mk

,您拥有适用于Android的.so文件.只需适当地更改ABI值即可.

and you have .so files for Android. Just change the ABI value appropriately.

这篇关于找不到入口点,Android .so文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆