Android NDK:load_library:找不到 srand

Android NDK: load_library: cannot locate srand(Android NDK:load_library:找不到 srand)

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

问题描述

我有一个 android 项目,我在其中使用本机代码来处理 SIP(​​使用 libosip2 和 libeXosip2).我的本机代码与库的源代码一起编译到一个模块中.

I have an android project where I use native code to do stuff with SIP (using libosip2 and libeXosip2). My native code is compiled together with the libraries' sources into one module.

代码编译得很好,生成的库具有我期望它具有的所有符号,但是当我尝试加载生成的库时,我收到以下错误:

The code compiles just fine and the generated library has all the symbols I expect it to have, but when I try to load the generated library I get the following error:

E/eXosip.loadLibrary(9210): java.lang.UnsatisfiedLinkError: Cannot load library: reloc_library[1307]:  1941 cannot locate 'srand'...

我的 Application.mk 如下所示:

My Application.mk looks like this:

APP_STL         := gnustl_shared
APP_ABI         := armeabi-v7a
APP_CPPFLAGS    += -fexceptions

我确实使用 ndk-depends 检查了未捕获的依赖项,这给了我

I did check for uncaught dependencies using ndk-depends, which gives me

libeXosip_jni.so
libstdc++.so
liblog.so
libgnustl_shared.so
libm.so
libdl.so
libc.so

添加 loadLibrary("gnustl_shared") 没有帮助(这是在libs/armeabi-v7/"中找到的唯一一个提到的库).

Adding a loadLibrary("gnustl_shared") does not help (which is the only one of the mentioned libraries also found in "libs/armeabi-v7/").

我的 Android.mk:

My Android.mk:

LOCAL_PATH  := $(call my-dir)
$(shell (cd $(LOCAL_PATH); sh extract_stuff.sh; cd $(OLDPWD)))


include $(CLEAR_VARS)
OSIP        := libosip2-4.1.0
EXOSIP      := libeXosip2-4.1.0
LOCAL_MODULE    := eXosip

LOCAL_C_INCLUDES    := $(LOCAL_PATH)/$(OSIP)/include 
                       $(LOCAL_PATH)/$(EXOSIP)/include

LOCAL_SRC_FILES := $(patsubst $(LOCAL_PATH)/%, %, $(wildcard $(LOCAL_PATH)/$(OSIP)/src/osipparser2/*.c)) 
                   $(patsubst $(LOCAL_PATH)/%, %, $(wildcard $(LOCAL_PATH)/$(OSIP)/src/osip2/*.c)) 
                   $(patsubst $(LOCAL_PATH)/%, %, $(wildcard $(LOCAL_PATH)/$(EXOSIP)/src/*.c))

LOCAL_CFLAGS += -DHAVE_FCNTL_H 
                -DHAVE_SYS_TIME_H 
                -DHAVE_STRUCT_TIMEVAL 
                -DHAVE_SYS_SELECT_H 
                -DHAVE_PTHREAD 
                -DHAVE_SEMAPHORE_H 
                -DENABLE_TRACE 
                -DOSIP_MT

include $(BUILD_STATIC_LIBRARY)


include $(CLEAR_VARS)
LOCAL_MODULE    := eXosip_jni
LOCAL_STATIC_LIBRARIES  := eXosip
LOCAL_LDLIBS := -llog 

LOCAL_C_INCLUDES := BackendData.h 
                    $(LOCAL_PATH)/$(EXOSIP)/include 
                    $(LOCAL_PATH)/$(OSIP)/include

LOCAL_SRC_FILES := eXosip.cpp 
                   eXosipCall.cpp

include $(BUILD_SHARED_LIBRARY)

C/C++ 不是我的刚毅,所以如果有人能启发我,我将非常感激 :) 作为替代方案,我的问题的解决方案也很好^^

C/C++ is not my fortitude, so if someone could enlighten me I'd be really grateful :) As an alternative, a solution to my problem would also be nice ^^

更新 1

我将 eXosip/osip 库从我的代码中分离出来,将其编译成一个静态库.我还测试了创建一个共享库并从 Java 内部手动加载它,它失败并显示相同的错误消息.

I separated the eXosip/osip library from my code, compiling it into a static library. I also tested creating a shared library and loading it by hand from inside Java, it fails with the same error message.

更新 2

我尝试使用 gnustl_shared、静态和 stlport - 错误仍然存​​在.

I tried using gnustl_shared, static and also stlport - the error remains.

推荐答案

感谢 Chris,我意识到自己的错误,即使用了 用于 64 位设备的 NDK.虽然我无法使用最小示例(它似乎特定于 libosip2 和可能的其他示例)复制错误,但使用 32 位 NDK 解决了该问题.

Thanks to Chris I realized my mistake, which was using the NDK intended for 64bit devices. Though I could not replicate the error using a minimal example (it seems to be specific to libosip2 and possibly others), using the 32bit NDK resolved the issue.

感谢所有花时间发表评论和建议的人!

Thank you everyone who took the time to comment and post suggestions!

这篇关于Android NDK:load_library:找不到 srand的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:Android NDK:load_library:找不到 srand