Android NDK UnsatisfiedLinkError:“dlopen failed:empty / missing DT_HASH” [英] Android NDK UnsatisfiedLinkError: "dlopen failed: empty/missing DT_HASH"

查看:5186
本文介绍了Android NDK UnsatisfiedLinkError:“dlopen failed:empty / missing DT_HASH”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用崩溃报告服务跟踪我们的Android应用程序(使用NDK加载C ++库)崩溃。少数用户遇到以下崩溃:

I am tracking down crashes with our Android application (which uses the NDK to load a C++ library) using a crash reporting service. A small number of users are experiencing the following crash:

java.lang.UnsatisfiedLinkError: dlopen failed: empty/missing DT_HASH in "cpplibrary.so" (built with --hash-style=gnu?)
   at java.lang.Runtime.loadLibrary(Runtime.java:365)
   at java.lang.System.loadLibrary(System.java:526)

这个错误的几个提到我可以在互联网上找到 Google网上论坛)讨论构建库的问题,这会导致此错误在每次运行应用程序时发生。有很少的信息,为什么这可能偶尔发生。 此信息是我可以找到的最近的信息。

The couple of mentions of this error I can find on the internet (for example this Google Groups post) discuss problems with building the libs, which cause this error to occur every time the app is run. There is little information on why this might happen sporadically. This post is the closest I can find.

基于崩溃轨迹,看起来任何特定的用户都会经常遇到这样的延伸;我不知道这些用户是否能够正确加载lib。有没有人有什么可能会导致这种情况只发生有时的想法?我可以用不同的NDK版本来尝试停止它吗?

Based on the crash traces, it looks like any particular user will experience this constantly for stretches; I am not sure if these users are ever able to load the lib correctly. Does anyone have ideas on what might cause this to happen only sometimes? Can I do the NDK build differently to try and stop it?

谢谢!

编辑:此帖子提到了两种有条件地获取此类错误的方法;

This post mentions two ways to get such errors conditionally; I will be looking in to them.

Edit2:构建文件:
Android.mk(摘录):

Build files: Android.mk (excerpt):

include $(CLEAR_VARS)
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)
LOCAL_C_INCLUDES := <Source Path>...
LOCAL_CFLAGS := -DANDROID -Wall
LOCAL_CPPFLAGS := -DENABLE_SDK_DEBUGGING=1 -DENABLE_SDK_LOGGING=1
LOCAL_MODULE := cpplibrary
LOCAL_SRC_FILES := <Source Files> / ...

LOCAL_LDLIBS    := -llog -landroid
LOCAL_STATIC_LIBRARIES := cpplibrary
include $(BUILD_SHARED_LIBRARY)

Application.mk:

Application.mk:

APP_STL := stlport_static
APP_CFLAGS += -std=c++11


推荐答案

您尝试加载的库最有可能是用 -Wl, - hash-style = gnu 构建的。这直到最近才在Android上不支持(afaik这甚至不是在L)。您需要使用 -Wl, - hash-style = sysv 构建您的库。

The library you are trying to load was most likely built with -Wl,--hash-style=gnu. This was not supported on Android until recently (afaik this isn't even in L). You need to build your libraries with -Wl,--hash-style=sysv.

cpplibrary.so ?如果你没有做任何事情手动切换到gnu哈希风格,它可能是NDK中的一个错误。

How did you build cpplibrary.so? If you didn't do anything to manually switch to the gnu hash style, it could be a bug in the NDK.

这篇关于Android NDK UnsatisfiedLinkError:“dlopen failed:empty / missing DT_HASH”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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