Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
949 views
in Technique[技术] by (71.8m points)

android - non-system libraries in linker flags

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)

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)

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

Any ideas?

EDIT: 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)
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

in your Android.mk; another - to run

ndk-build OPENCV_INSTALL_MODULES=on

from command line.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...