gpt4 book ai didi

android - OpenCV Android 实现与 CMAKE undefined reference 'cv::fastFree(void*) 错误

转载 作者:太空宇宙 更新时间:2023-11-03 23:11:02 24 4
gpt4 key购买 nike

我正在尝试在 Android 中使用 CMAKE 实现 OpenCV310。我同时使用 dlib 库和 OpenCV 库。 Example project github link

在这个 github 链接中,它调用了 Android NDK 上的 dlib 库中的 opencv 方法。我正在尝试用 CMAKE 自己实现这个项目。我尝试从一个简单的 native-lib.cpp 文件调用 openCV。它的工作。但是当我添加 dlib 时它开始给出错误。

Error:(571) undefined reference to 'cv::fastFree(void*)'
Error:(682) undefined reference to 'cv::Mat::deallocate()'

这是我的 CMAKE 文件。

cmake_minimum_required(VERSION 3.4.1)


set(CMAKE_VERBOSE_MAKEFILE on)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")

set(pathToProject C:/Users/lenovo/AndroidStudioProjects/AdviserOpenCV3)
set(pathToOpenCV C:/Users/lenovo/Desktop/openCV310/OpenCV-3.1.0-android-sdk/OpenCV-android-sdk)

set(JNI_DETECTION_INCLUDE src/main/jni/jni_detections)
set(JNI_DETECTION_SRC src/main/jni/jni_detections)
set(JNI_COMMON_INCLUDE src/main/jni)
set(JNI_COMMON_SRC src/main/jni/jni_common)
set(DLIB_DIR src/main/dlib)
set(EXT_DIR src/main/third_party)

include_directories(${pathToOpenCV}/sdk/native/jni/include)
#include_directories(${DLIB_DIR} ${JNI_COMMON_INCLUDE} ${JNI_DETECTION_INCLUDE} include)

add_library( lib_opencv SHARED IMPORTED)

set_target_properties(lib_opencv PROPERTIES IMPORTED_LOCATION
${pathToProject}/app/src/main/jniLibs/${ANDROID_ABI}/libopencv_java3.so)

add_library(android_dlib SHARED
${JNI_DETECTION_SRC}/jni_face_det.cpp
${JNI_DETECTION_SRC}/jni_imageutils.cpp
${JNI_DETECTION_SRC}/jni_pedestrian_det.cpp
${JNI_COMMON_SRC}/jni_bitmap2mat.cpp
${JNI_COMMON_SRC}/jni_fileutils.cpp
${JNI_COMMON_SRC}/jni_utils.cpp
${JNI_COMMON_SRC}/rgb2yuv.cpp
${JNI_COMMON_SRC}/yuv2rgb.cpp
${DLIB_DIR}/threads/threads_kernel_shared.cpp
${DLIB_DIR}/entropy_decoder/entropy_decoder_kernel_2.cpp
${DLIB_DIR}/base64/base64_kernel_1.cpp
${DLIB_DIR}/threads/threads_kernel_1.cpp
${DLIB_DIR}/threads/threads_kernel_2.cpp
${EXT_DIR}/glog/logging.cc)


add_library( # Sets the name of the library.
native-lib

# Sets the library as a shared library.
SHARED

# Provides a relative path to your source file(s).
src/main/cpp/native-lib.cpp )

# Searches for a specified prebuilt library and stores the path as a
# variable. Because CMake includes system libraries in the search path by
# default, you only need to specify the name of the public NDK library
# you want to add. CMake verifies that the library exists before
# completing its build.

find_library( # Sets the name of the path variable.
log-lib

# Specifies the name of the NDK library that
# you want CMake to locate.
log )

# Specifies libraries CMake should link to your target library. You
# can link multiple libraries, such as libraries you define in this
# build script, prebuilt third-party libraries, or system libraries.

target_link_libraries( # Specifies the target library.
android_dlib
lib_opencv
# Links the target library to the log library
# included in the NDK.
$\{log-lib} )

我该如何解决这个问题?感谢你的贡献。最好的问候,

最佳答案

您应该声明native-liblib_opencv 之间的依赖关系。你可能也想要 android_dlib:

target_link_libraries(
native-lib
android_dlib
lib_opencv
# Links the target library to the log library
# included in the NDK.
log )

正如您在上面看到的,您的脚本中不需要${log-lib}; Android NDK 为您定义了日志库。

关于android - OpenCV Android 实现与 CMAKE undefined reference 'cv::fastFree(void*) 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49981707/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com