链接器标志中的非系统库

时间:2014-07-10 06:07:52

标签: android eclipse opencv android-ndk

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

编译时,控制台输出如下:

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如下:

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的任何地方。

有什么想法吗?

编辑:回应Alex Cohn的提问。如果我在“include $(CLEAR_VARS)”之前的行中添加“$(info == $(OPENCV_INSTALL_MODULES)==)”,则控制台会报告以下内容:

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)

1 个答案:

答案 0 :(得分:7)

include OpenCV.mk之前,您必须确保$(OPENCV_INSTALL_MODULES)等于 。您的OPENCV_INSTALL_MODULES:=on文件中有Android.mk行,但由于某种原因它无效。如果不深入研究所有可能的(也是不可能的)问题,解决问题的简单方法就是编写

override OPENCV_INSTALL_MODULES:=on

Android.mk;另一个 - 运行

ndk-build OPENCV_INSTALL_MODULES=on

来自命令行。