Android的NDK连接问题 [英] Android NDK linking problems

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

问题描述

我编袜等与NDK。所以,我有所有的Andr​​oid友好的共享库。

I compiled Sox et al with NDK. So, I have all Android-friendly shared libs.

我做了一个它调用一个函数SOX简单的测试文件
NDK构建告诉我:

I made a simple test file which calls a sox function. NDK build tells me:

undefined reference to `sox_open_read'

sox_open_read在sox.h.定义我知道这是发现sox.h,因为它给了我一个有关文件警告:

sox_open_read is defined in sox.h. I know it's finding sox.h because it gives me a warning about that file:

In file included from (...)/sox/sox.h:19

所以,或许是要在实际libsox.so sox_open_read找到。嗯,我已经试过约100不同的方式来告诉它的SOX共享库是例如

So maybe it wants to find sox_open_read in the actual libsox.so. Well, I've tried about a 100 different ways to tell it where the sox shared lib is e.g.

LOCAL_SHARED_LIBRARY := sox
LOCAL_LDLIBS    := -L$(LOCAL_PATH_FULL)/jni/libs/libsox.so

但是,它会如果我指定红袜作为静态库工作:

However, It will work if I specify Sox as a static library:

#LOCAL_SHARED_LIBRARY := sox
LOCAL_STATIC_LIBRARIES := sox
LOCAL_LDLIBS    := -L$(LOCAL_PATH_FULL)/jni/libs/libsox.so

这是我的理解,我不想staticly链接到SOX LIB - 我要动态链接到它。

It's my understanding that I don't want to staticly link to the sox lib - I want to dynamically link to it.

推荐答案

您应该定义libsox.so为prebuilt库。创建一个makefile如下,把你的prebuilt libsox.so在同一目录与此生成的文件。在这之后,你可以使用libsox一样你重建它。不要忘了,包括这个makefile到您的构建。

You should define libsox.so as a prebuilt library. Create a makefile as the following and put your prebuilt libsox.so in the same directory with this makefile. After that, you can use libsox same as you've rebuilt it. Don't forget to include this makefile into your build.

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE := libsox
LOCAL_SRC_FILES := libsox.so

include $(PREBUILT_SHARED_LIBRARY)

这篇关于Android的NDK连接问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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