警告:... / Android.mk:在连接标志非系统库 [英] WARNING: .../Android.mk: non-system libraries in linker flags

查看:3092
本文介绍了警告:... / Android.mk:在连接标志非系统库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我运行时得到这个警告 $ ANDROID_NDK_ROOT / NDK建造。该 Android.mk 如下。

I'm getting this warning while running $ANDROID_NDK_ROOT/ndk-build. The Android.mk is below.

$ $ANDROID_NDK_ROOT/ndk-build 

WARNING:/Users/jwalton/Android-CryptoPP/jni/Android.mk:prng:
    non-system libraries in linker flags: -lcryptopp -lstlport_shared    
    This is likely to result in incorrect builds. Try using LOCAL_STATIC_LIBRARIES    
    or LOCAL_SHARED_LIBRARIES instead to list the library dependencies of the
    current module
...

然而,当我按照说明进行操作,并删除 -lcryptopp -lstlport_shared LOCAL_LDLIBS ,然后我得到链接错误与符号从 libstlport_shared.so 。错误的样本如下所示的 Android.mk 文件之后。

However, when I follow the instructions and remove -lcryptopp -lstlport_shared from LOCAL_LDLIBS, then I get link errors related to symbols from libstlport_shared.so. A sample of the errors are shown below after the Android.mk file.

如何,究竟是否 NDK建造希望 Android.mk 设置?

How, exactly, does ndk-build want Android.mk set up?

为什么我一定要添加 $(STLPORT_INCL) LOCAL_C_INCLUDES $ (STLPORT_LIB) LOCAL_LDFLAGS ?为什么 APP_STL:= stlport_shared 没有的设置STL正确的开箱即用

Why do I have to add $(STLPORT_INCL) to LOCAL_C_INCLUDES, and $(STLPORT_LIB) to LOCAL_LDFLAGS? Why does APP_STL := stlport_shared not setup the STL correctly out of the box?

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

TARGET_ARCH_ABI := armeabi
TARGET_ABI      := android-9-armeabi

CRYPTOPP_INCL   := /usr/local/cryptopp-android-9/include
CRYPTOPP_LIB    := /usr/local/cryptopp-android-9/lib

STLPORT_INCL    := /opt/android-ndk-r9/sources/cxx-stl/stlport/stlport
STLPORT_LIB     := /opt/android-ndk-r9/sources/cxx-stl/stlport/libs/armeabi

APP_STL         := stlport_shared
APP_MODULES     := stlport_shared cryptopp

LOCAL_CPP_FEATURES := rtti exceptions

LOCAL_C_INCLUDES := $(CRYPTOPP_INCL) $(CRYPTOPP_INCL)/cryptopp $(STLPORT_INCL)

LOCAL_LDFLAGS  := -L $(CRYPTOPP_LIB) -L $(STLPORT_LIB)
LOCAL_LDLIBS   := -lcryptopp -lstlport_shared -llog -landroid
# LOCAL_LDLIBS   := -llog -landroid
# LOCAL_SHARED_LIBRARIES := -lcryptopp -lstlport_shared

LOCAL_MODULE    := prng
LOCAL_SRC_FILES := libprng.cpp

include $(BUILD_SHARED_LIBRARY)


下面是当试图通过删除我的本地库照做错误的样本 LOCAL_LDLIBS

$ $ANDROID_NDK_ROOT/ndk-build 
Android NDK: WARNING: APP_PLATFORM android-14 is larger than android:minSdkVersion 9 in /Users/jwalton/Android-CryptoPP/AndroidManifest.xml    
Gdbserver      : [arm-linux-androideabi-4.6] libs/armeabi/gdbserver
Gdbsetup       : libs/armeabi/gdb.setup
Compile++ thumb  : prng <= libprng.cpp
SharedLibrary  : libprng.so
/opt/android-ndk-r9/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: /Users/jwalton/Android-CryptoPP/obj/local/armeabi/objs-debug/prng/libprng.o: in function std::__node_alloc::allocate(unsigned int&):/opt/android-ndk-r9/sources/cxx-stl/stlport/stlport/stl/_alloc.h:158: error: undefined reference to 'std::__node_alloc::_M_allocate(unsigned int&)'
/opt/android-ndk-r9/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: /Users/jwalton/Android-CryptoPP/obj/local/armeabi/objs-debug/prng/libprng.o: in function std::__node_alloc::deallocate(void*, unsigned int):/opt/android-ndk-r9/sources/cxx-stl/stlport/stlport/stl/_alloc.h:161: error: undefined reference to 'std::__node_alloc::_M_deallocate(void*, unsigned int)'
/opt/android-ndk-r9/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: /Users/jwalton/Android-CryptoPP/obj/local/armeabi/objs-debug/prng/libprng.o: in function std::ios_base::_M_check_exception_mask():/opt/android-ndk-r9/sources/cxx-stl/stlport/stlport/stl/_ios_base.h:193: error: undefined reference to 'std::ios_base::_M_throw_failure()'

...

推荐答案

我除preT消息为警告,您不使用默认的系统库(在在连接标志非系统库 usr / lib目录),这可能是完全正常的,但也可能导致错误(不同的库版本之间的不兼容)。无论此警告的错误,你是完全取决于你。

I interpret the "non-system libraries in linker flags" message as a warning that you're not using the default system libraries (in usr/lib) which may be perfectly fine, but which could also lead to errors (incompatibility between different libraries versions). Whether this warning bugs you is completely up to you.

然后,你试图解决它的方式,我觉得你用错误的NDK的 LOCAL_SHARED_LIBRARIES 变量。

Then, about the way you tried to solve it, I think you're using wrongly the LOCAL_SHARED_LIBRARIES variable of the NDK.

我贴在这里的样品从我的 Android.mk 文件,它使用Assimp之一

I paste here a sample from one of my Android.mk file which uses Assimp

#------------------------------------------------------------------ Assimp
include $(CLEAR_VARS)

LOCAL_MODULE := Assimp
LOCAL_EXPORT_C_INCLUDES := $(GENERATED_INCLUDE_PATH)/assimp/include
LOCAL_SRC_FILES := $(GENERATED_PATH)/assimp/lib/libassimp.a

include $(PREBUILT_STATIC_LIBRARY)

...

LOCAL_STATIC_LIBRARIES := \
Assimp \
<Your other libs here>

正如你所看到的,我宣布一个 LOCAL_MODULE 使用自定义名称,设置几个变量,然后包括 preBUILT_STATIC_LIBRARY 脚本,它告诉NDK使用这个库。

As you can see, I declare a LOCAL_MODULE with a custom name, set up a few variables and then include the PREBUILT_STATIC_LIBRARY script which tells the NDK to use this lib.

然后在 LOCAL_STATIC_LIBRARIES 我列出库我使用与模块名,不作为,如果这是一个链接器标志像你这样做在这里。

Then in LOCAL_STATIC_LIBRARIES I list the libraries I use with their module name, not as if this was a linker flag like you're doing here.

在你的情况,我相信你应该做到以下几点,例如用于STL

In your case, I believe you should do the following, for example for the stl

include $(CLEAR_VARS)

LOCAL_MODULE := STLPortShared
LOCAL_EXPORT_C_INCLUDES := <path to stlport includes>
LOCAL_SRC_FILES := <path to stlport library>

include $(PREBUILT_SHARED_LIBRARY)

...
#Notice the name, identical to the one specified for LOCAL_MODULE
LOCAL_SHARED_LIBRARIES = STLPortShared 

我想这应该这样做。当然,重复上述过程,每个库导致的麻烦,也不要忘了包括(CLEAR_VARS)每个LIB规范之间的。

I think this should do it. Of course, repeat the process for each libs that causes trouble, and don't forget the include(CLEAR_VARS) between each lib specification.

这篇关于警告:... / Android.mk:在连接标志非系统库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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