Android Studio NDK链接器错误未定义对'cv :: _ OutputArray :: _ OutputArray(cv :: Mat&)的引用 [英] Android Studio NDK linker error undefined reference to 'cv::_OutputArray::_OutputArray(cv::Mat&)'
问题描述
我正在使用NDK的Android项目中工作,在该项目中,我已经使用opencv进行了一些捕获和图像效果处理.这是我的Android.mk的样子:
I'm working on an Android project which uses NDK, in which I have used opencv for some capture and image effects stuff. Here's how my Android.mk look like:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
include path/to/OpenCV.mk
LOCAL_MODULE := Scanner
LOCAL_SRC_FILES := scan.cpp
LOCAL_LDLIBS += -lz -lm -llog -landroid -ldl -lstdc++
LOCAL_LDFLAGS += -ljnigraphics -fexceptions -std=c++11 -L$(LOCAL_PATH)/sdk/native/jni/libs/armeabi-v7a -L$(LOCAL_PATH)/sdk/native/jni/3rdparty/libs/armeabi-v7a -I$(LOCAL_PATH)/sdk/native/jni/include -I$(LOCAL_PATH)/sdk/native/jni/include/opencv2/core -I$(LOCAL_PATH)/sdk/native/jni/include/opencv2/calib3d -I$(LOCAL_PATH)/sdk/native/jni/include/opencv2/contrib -I$(LOCAL_PATH)/sdk/native/jni/include/opencv2/features2d -I$(LOCAL_PATH)/sdk/native/jni/include/opencv2/flann -I$(LOCAL_PATH)/sdk/native/jni/include/opencv2/highgui -I$(LOCAL_PATH)/sdk/native/jni/include/opencv2/imgproc -I$(LOCAL_PATH)/sdk/native/jni/include/opencv2/legacy -I$(LOCAL_PATH)/sdk/native/jni/include/opencv2/ml -I$(LOCAL_PATH)/sdk/native/jni/include/opencv2/objdetect -I$(LOCAL_PATH)/sdk/native/jni/include/opencv2/ocl -I$(LOCAL_PATH)/sdk/native/jni/include/opencv2/photo -I$(LOCAL_PATH)/sdk/native/jni/include/opencv2/stitching -I$(LOCAL_PATH)/sdk/native/jni/include/opencv2/superres -I$(LOCAL_PATH)/sdk/native/jni/include/opencv2/ts -I$(LOCAL_PATH)/sdk/native/jni/include/opencv2/video -I$(LOCAL_PATH)/sdk/native/jni/include/opencv2/videostab -I$(LOCAL_PATH)/sdk/native/jni/include/opencv2
LOCAL_STATIC_LIBRARIES := opencv_shape opencv_stitching opencv_objdetect opencv_superres opencv_videostab opencv_calib3d opencv_features2d opencv_highgui opencv_videoio opencv_imgcodecs opencv_video opencv_photo opencv_ml opencv_flann opencv_imgproc opencv_core opencv_ts IlmImf libjasper libjpeg libpng libtiff libwebp tbb
include $(BUILD_SHARED_LIBRARY)
尽管我链接了所有opencv库并指定了正确的路径(通过更改路径进行了验证),但出现了以下链接器错误:
Though I'm linking all opencv libraries and specifying the correct path(verified it by chaning paths) I'm getting the following linker error:
../sdk/native/jni/include/opencv2/core/mat.hpp:335: error: undefined reference to 'cv::_OutputArray::_OutputArray(cv::Mat&)'
jni/scan.cpp:33: error: undefined reference to 'cv::_InputArray::_InputArray(cv::Mat const&)'
jni/scan.cpp:33: error: undefined reference to 'cv::_OutputArray::_OutputArray(cv::Mat&)'
jni/scan.cpp:65: error: undefined reference to 'cv::_InputArray::_InputArray(cv::Mat const&)'
jni/scan.cpp:65: error: undefined reference to 'cv::_InputArray::_InputArray(cv::Mat const&)'
jni/scan.cpp:72: error: undefined reference to 'cv::_InputArray::_InputArray(cv::Mat const&)'
jni/scan.cpp:48: error: undefined reference to 'cv::_OutputArray::_OutputArray(cv::Mat&)'
jni/scan.cpp:51: error: undefined reference to 'cv::_OutputArray::_OutputArray(cv::Mat&)'
jni/scan.cpp:58: error: undefined reference to 'cv::findContours(cv::_OutputArray const&, cv::_OutputArray const&, int, int, cv::Point_<int>)'
..sdk/native/jni/include/opencv2/core/mat.hpp:276: error: undefined reference to 'vtable for cv::_OutputArray'
..Android/sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: the vtable symbol may be undefined because the class is missing its key function
..sdk/native/jni/include/opencv2/core/mat.hpp:276: error: undefined reference to 'vtable for cv::_OutputArray'
..Android/sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: the vtable symbol may be undefined because the class is missing its key function
jni/scan.cpp:162: error: undefined reference to 'cv::findContours(cv::_OutputArray const&, cv::_OutputArray const&, int, int, cv::Point_<int>)'
..sdk/native/jni/include/opencv2/core/mat.hpp:276: error: undefined reference to 'vtable for cv::_OutputArray'
/Users/mtsindia/Library/Android/sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: the vtable symbol may be undefined because the class is missing its key function
..sdk/native/jni/include/opencv2/core/mat.hpp:276: error: undefined reference to 'vtable for cv::_OutputArray'
..Android/sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: the vtable symbol may be undefined because the class is missing its key function
jni/scan.cpp:261: error: undefined reference to 'vtable for cv::_InputArray'
..Android/sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: the vtable symbol may be undefined because the class is missing its key function
jni/scan.cpp:296: error: undefined reference to 'cv::Exception::Exception(int, std::string const&, std::string const&, std::string const&, int)'
jni/scan.cpp:297: error: undefined reference to 'cv::Exception::Exception(int, std::string const&, std::string const&, std::string const&, int)'
jni/scan.cpp:298: error: undefined reference to 'cv::Exception::Exception(int, std::string const&, std::string const&, std::string const&, int)'
jni/scan.cpp:299: error: undefined reference to 'cv::Exception::Exception(int, std::string const&, std::string const&, std::string const&, int)'
这是链接,我在其中下载了扫描仪应用程序演示并在scan.cpp
文件中进行了修改并尝试重建库.
我已经在Android Studio中将ndk-build创建为外部工具,并且也验证了ndk路径.我在这里想念什么?任何帮助将不胜感激.
This is the link where I downloaded the scanner app demo and made modifications in scan.cpp
file and trying to rebuild the library.
I have created ndk-build as an external tool in Android studio, verified the ndk path too. What am I missing here? Any help would be appreciated.
推荐答案
修复了该问题.我不知道确切的原因如何解决.我还原了在Android.mk,Application.mk和OpenCV.mk中所做的所有更改,现在我的Adnroid.mk看起来像这样:
Fixed it. I dont know the exact reason how it get fixed. I reverted all the changes I've made in Android.mk , Application.mk and OpenCV.mk, Now my Adnroid.mk looks like this:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
OPENCV_INSTALL_MODULES:=on
include $(LOCAL_PATH)/sdk/native/jni/OpenCV.mk
LOCAL_MODULE := Scanner
LOCAL_SRC_FILES := scan.cpp
LOCAL_LDLIBS += -lm -llog -landroid
LOCAL_LDFLAGS += -ljnigraphics
include $(BUILD_SHARED_LIBRARY)
和Application.mk:
And Application.mk:
APP_STL := stlport_static
APP_CPPFLAGS := -frtti -fexceptions
APP_ABI := all
APP_PLATFORM := android-14
这是我的OpenCV.mk的样子:
And here's how my OpenCV.mk looks like:
我想我错过了指定正确的路径,否则我的库文件(.so和.a)的版本可能与包含的头文件不同.如果有人有其他想法,请发表评论.
I guess I have missed specyfying the correct path or my library files(.so and .a) might be of different versions than the header files included. If anyone got other ideas, please post a comment.
这篇关于Android Studio NDK链接器错误未定义对'cv :: _ OutputArray :: _ OutputArray(cv :: Mat&)的引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!