簡體   English   中英

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 的樣子:

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 庫並指定正確的路徑(通過更改路徑對其進行驗證),但我收到以下鏈接器錯誤:

../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 路徑。 我在這里缺少什么? 任何幫助,將不勝感激。

修復。 我不知道它是如何修復的確切原因。 我恢復了我在 Android.mk、Application.mk 和 OpenCV.mk 中所做的所有更改,現在我的 Adnroid.mk 看起來像這樣:

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:

APP_STL := stlport_static
APP_CPPFLAGS := -frtti -fexceptions
APP_ABI := all
APP_PLATFORM := android-14

這是我的 OpenCV.mk 的樣子:

https://pastebin.com/zuqM6tbu

我想我沒有指定正確的路徑,或者我的庫文件(.so 和 .a)可能與包含的頭文件的版本不同。 如果有人有其他想法,請發表評論。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM