ข้อผิดพลาดตัวเชื่อมโยง Android Studio NDK ไม่ได้กำหนดการอ้างอิงถึง 'cv :: _OutputArray :: _OutputArray (cv :: Mat &)'

ฉันกำลังทำงานในโปรเจ็กต์ Android ที่ใช้ NDK ซึ่งฉันใช้ 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 และพยายามสร้างใหม่ ห้องสมุด. ฉันได้สร้าง ndk-build เป็นเครื่องมือภายนอกใน Android studio แล้วตรวจสอบเส้นทาง ndk ด้วย ฉันพลาดอะไรไปที่นี่? ความช่วยเหลือใด ๆ ที่จะได้รับการชื่นชม


person Karthik Sivam    schedule 20.12.2017    source แหล่งที่มา
comment
คิดว่า -lstdc++ ไม่ควรใช้   -  person Alex Cohn    schedule 21.12.2017
comment
LOCAL_STATIC_LIBRARIES += ด้วย + แทนที่จะเป็น :   -  person Alex Cohn    schedule 21.12.2017
comment
@AlexCohn ขอบคุณ ลองทั้งสองอย่างแล้ว แต่ฉันก็ยังได้รับข้อผิดพลาดเดียวกัน   -  person Karthik Sivam    schedule 21.12.2017


คำตอบ (1)


ซ่อมมัน. ฉันไม่ทราบสาเหตุที่แน่ชัดว่าจะแก้ไขได้อย่างไร ฉันคืนค่าการเปลี่ยนแปลงทั้งหมดที่ฉันทำใน 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) อาจมีเวอร์ชันที่แตกต่างจากไฟล์ส่วนหัวที่รวมอยู่ หากใครมีความคิดอื่น ๆ โปรดแสดงความคิดเห็น

person Karthik Sivam    schedule 21.12.2017
comment
ดี. โปรดทราบว่า OpenCV คาดหวัง APP_STL=gnustl_static ที่จริงแล้วมันเป็นตัวเลือกที่ดีกว่า stlport ในกรณีส่วนใหญ่ - person Alex Cohn; 21.12.2017