链接器标志中的非系统库

non-system libraries in linker flags(链接器标志中的非系统库)
本文介绍了链接器标志中的非系统库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我有一个使用一些 C++ 和 OpenCV 的完整工作应用程序.它编译并成功运行.现在我只是想整理我的代码并进行更改以在编译时删除所有警告.但是有一个警告我不明白.我的 android.mk 似乎有问题.

I have a fully working app employing some C++ and OpenCV. It compiles and runs successfully. Right now I am just trying to tidy my code and make changes to remove all warnings at compile time. But there is one warning I don't understand. It appears to be a problem with my android.mk.

我编译的时候控制台输出如下:

When I compile, the console output is as follows:

06:58:21 **** Incremental Build of configuration Default for project Motion ****
"C:\android-ndk-r9c\ndk-build.cmd" all 
Android NDK: WARNING:jni/Android.mk:mixed_sample: non-system libraries in linker flags: -lopencv_java    
Android NDK:     This is likely to result in incorrect builds. Try using LOCAL_STATIC_LIBRARIES    
Android NDK:     or LOCAL_SHARED_LIBRARIES instead to list the library dependencies of the    
Android NDK:     current module    
[armeabi-v7a] Compile++ thumb: mixed_sample <= cpp_part.cpp
[armeabi-v7a] SharedLibrary  : libmixed_sample.so
C:/android-ndk-r9c/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: warning: hidden symbol '__aeabi_atexit' in C:/android-ndk-r9c/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi-v7a/libgnustl_static.a(atexit_arm.o) is referenced by DSO c:/opencv-2.4.8-android-sdk/sdk/native/jni/../libs/armeabi-v7a/libopencv_java.so
[armeabi-v7a] Install        : libmixed_sample.so => libs/armeabi-v7a/libmixed_sample.so

06:58:24 Build Finished (took 2s.515ms)

我的android.mk如下:

My android.mk is as follows:

LOCAL_PATH := $(call my-dir)

# compile with profiling
LOCAL_CFLAGS := -pg

include $(CLEAR_VARS)

 OPENCV_CAMERA_MODULES:=off 
 OPENCV_INSTALL_MODULES:=on 
 OPENCV_LIB_TYPE:=SHARED

include c:opencv-2.4.8-android-sdk/sdk/native/jni/OpenCV.mk

LOCAL_MODULE    := mixed_sample
LOCAL_SRC_FILES := cpp_part.cpp
LOCAL_LDLIBS +=  -llog -ldl -lz

LOCAL_STATIC_LIBRARIES := android-ndk-profiler

include $(BUILD_SHARED_LIBRARY)

$(call import-module,android-ndk-profiler)

我什至无法弄清楚-lopencv_java"链接器标志的来源,它没有出现在 android.mk 中的任何位置.

I can't even work out where the "-lopencv_java" linker flag comes from, it doesn't appear anywhere in android.mk.

有什么想法吗?

回答 Alex Cohn 的问题.如果我在include $(CLEAR_VARS)"之前的行中添加$(info ==$(OPENCV_INSTALL_MODULES)==)",那么控制台会报告以下内容:

In response to Alex Cohn's question. If I add "$(info ==$(OPENCV_INSTALL_MODULES)==)" in the line preceding "include $(CLEAR_VARS)" then the console reports the following:

08:39:34 **** Incremental Build of configuration Default for project Motion ****
"C:\android-ndk-r9c\ndk-build.cmd" all 
====
Android NDK: WARNING:jni/Android.mk:mixed_sample: non-system libraries in linker flags: -lopencv_java    
Android NDK:     This is likely to result in incorrect builds. Try using LOCAL_STATIC_LIBRARIES    
Android NDK:     or LOCAL_SHARED_LIBRARIES instead to list the library dependencies of the    
Android NDK:     current module    
[armeabi-v7a] Compile++ thumb: mixed_sample <= cpp_part.cpp
[armeabi-v7a] SharedLibrary  : libmixed_sample.so
C:/android-ndk-r9c/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: warning: hidden symbol '__aeabi_atexit' in C:/android-ndk-r9c/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi-v7a/libgnustl_static.a(atexit_arm.o) is referenced by DSO c:/opencv-2.4.8-android-sdk/sdk/native/jni/../libs/armeabi-v7a/libopencv_java.so
[armeabi-v7a] Install        : libmixed_sample.so => libs/armeabi-v7a/libmixed_sample.so

08:39:36 Build Finished (took 2s.564ms)

推荐答案

在你include OpenCV.mk之前,你必须确保$(OPENCV_INSTALL_MODULES)等于<强>开.您的 Android.mk 文件中有 OPENCV_INSTALL_MODULES:=on 行,但由于某种原因它不起作用.在不深入研究所有可能(和不可能)的问题的情况下,解决问题的一种简单方法是编写

Before you include OpenCV.mk, you must make sure that $(OPENCV_INSTALL_MODULES) is equal on. You have the line OPENCV_INSTALL_MODULES:=on in your Android.mk file, but for some reason it did not work. Without digging into all possible (and impossible) problems, an easy way to fix the problem is to write

override OPENCV_INSTALL_MODULES:=on

在您的 Android.mk 中;另一个 - 运行

in your Android.mk; another - to run

ndk-build OPENCV_INSTALL_MODULES=on

从命令行.

这篇关于链接器标志中的非系统库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Creating RSA Public Key From String(从字符串创建 RSA 公钥)
Encrypt with Node.js Crypto module and decrypt with Java (in Android app)(使用 Node.js Crypto 模块加密并使用 Java 解密(在 Android 应用程序中))
How to hash a string in Android?(如何在Android中对字符串进行哈希处理?)
How to validate Safety Net JWS signature from header data in Android app(如何从 Android 应用程序中的标头数据验证 Safety Net JWS 签名)
How can I decode JWT token in android?(如何在 android 中解码 JWT 令牌?)
BitmapFactory﹕ Unable to decode stream - null(BitmapFactory:无法解码流 - null)