gpt4 book ai didi

android - 错误 : undefined reference to 'cv::String::deallocate()'

转载 作者:行者123 更新时间:2023-12-02 17:58:09 28 4
gpt4 key购买 nike

我尝试将 opencv lib 添加到我的原生 android 项目中。为了做到这一点,我在我的 CMake 文件中添加了 opencv 的路径

# For more information about using CMake with Android Studio, read the
# documentation: https://d.android.com/studio/projects/add-native-code.html

cmake_minimum_required(VERSION 3.4.1)

set(pathToOpenCv D:\\OpenCV-android-sdk)
set(CMAKE VERBOSE MAKEFILE on)
set(CMAKE CXX FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")

set(PARSER_TET_DIR ../../../co_FileCodec)
set(PARSER__DIR_ENGINE ../../../co_FileCodec_Engine/co_DecoderEngine)
set(PARSER_GWS_DIR ../../../GWStdLib)

include_directories(${pathToOpenCv}/sdk/native/jni/include)
add_library(lib_opencv SHARED IMPORTED)
set_target_properties(lib_opencv PROPERTIES IMPORTED_LOCATION
${pathToOpenCv}/sdk/native/libs/${CMAKE_ANDROID_ARCH_ABI}/libopencv_java3.so)

set(decoder_engine_source
src/main/cpp/co_DecoderEngineAndroidApi.cpp
src/main/cpp/texture_decoder/texture_codec.cpp
src/main/cpp/util/util.cpp
)

add_library( # Sets the name of the library.
co_decoder_engine_android_lib

# Sets the library as a shared library.
SHARED

# Provides a relative path to your source file(s).
${decoder_engine_source} )

# libcodec
set(_codec_source
${PARSER__DIR}/co_Decoder/co_MtrDecoder.cpp
${PARSER__DIR}/co_Decoder/co_Decoder.cpp
)

add_library(libcodec SHARED ${_codec_source})

include_directories(src/main/cpp)
include_directories(${PARSER__DIR})
include_directories(${PARSER__DIR}/co_Decoder)
include_directories(${PARSER__DIR}/co_Shared)
include_directories(${PARSER_GWS_DIR})

include_directories(${PARSER__DIR_ENGINE})

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 )

target_compile_options(co_decoder_engine_android_lib PRIVATE
"$<$<CONFIG:RELEASE>:-O3>"
"$<$<CONFIG:DEBUG>:-O0>")

target_compile_options(libcodec PRIVATE
"$<$<CONFIG:RELEASE>:-O3>"
"$<$<CONFIG:DEBUG>:-O0>")

target_link_libraries( # Specifies the target library.
co_decoder_engine_android_lib
mediandk
android
lib_opencv
libcodec
${log-lib} )
然后我尝试添加这个包括 #include "opencv2/opencv.hpp"给我的 .cpp文件
但我收到这样的错误
ninja: Entering directory `D:\co_repo\com_main\co_Infrastructure\Tier1.0\co_FileCodec_Engine\DecoderEngineBuilder\co_decoder_engine_android\.cxx\cmake\debug\x86'
[1/3] Building CXX object CMakeFiles/libcodec.dir/01a7033fdca6735bc52cb367da99f647/co_DecoderEngine/co_DecoderStream.cpp.o
[2/3] Linking CXX shared library ..\..\..\..\build\intermediates\cmake\debug\obj\x86\liblibcodec.so
FAILED: ../../../../build/intermediates/cmake/debug/obj/x86/liblibcodec.so
cmd.exe /C "cd . && C:\Users\track\AppData\Local\Android\Sdk\ndk\20.0.5594570\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++.exe --target=i686-none-linux-android24 --gcc-toolchain=C:/Users/track/AppData/Local/Android/Sdk/ndk/20.0.5594570/toolchains/llvm/prebuilt/windows-x86_64 --sysroot=C:/Users/track/AppData/Local/Android/Sdk/ndk/20.0.5594570/toolchains/llvm/prebuilt/windows-x86_64/sysroot -fPIC -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -fno-addrsig -Wa,--noexecstack -Wformat -Werror=format-security -std=c++17 -Wall -O0 -fno-limit-debug-info -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libatomic.a -static-libstdc++ -Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings -Wl,--no-undefined -Qunused-arguments -Wl,-z,noexecstack -shared -Wl,-soname,liblibcodec.so -o ..\..\..\..\build\intermediates\cmake\debug\obj\x86\liblibcodec.so CMakeFiles/libcodec.dir/e17dc0da4ce9741e6542b9ad403a181e/co_FileCodec/co_Decoder/co_MtrDecoder.cpp.o CMakeFiles/libcodec.dir/e17dc0da4ce9741e6542b9ad403a181e/co_FileCodec/co_Decoder/co_Decoder.cpp.o CMakeFiles/libcodec.dir/a4eab3dee2189f67213cbef1e5027e5a/co_Decoder/co_DecoderImpl.cpp.o CMakeFiles/libcodec.dir/a4eab3dee2189f67213cbef1e5027e5a/co_Decoder/co_ChunkBuffers.cpp.o CMakeFiles/libcodec.dir/e17dc0da4ce9741e6542b9ad403a181e/co_FileCodec/co_Shared/co_Texture.cpp.o CMakeFiles/libcodec.dir/D_/co_repo/com_main/co_Infrastructure/Tier1.0/GWStdLib/GWS_Basics.cpp.o CMakeFiles/libcodec.dir/01a7033fdca6735bc52cb367da99f647/co_DecoderEngine/co_DecoderStream.cpp.o -latomic -lm && cd ."
D:/OpenCV-android-sdk/sdk/native/jni/include\opencv2/core/cvstd.hpp:648: error: undefined reference to 'cv::String::deallocate()'
D:/OpenCV-android-sdk/sdk/native/jni/include\opencv2/core/cvstd.hpp:656: error: undefined reference to 'cv::String::deallocate()'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
我已经检查了所有内容,我做错了什么?

最佳答案

如果 nm (dumpbin.exe 对于 Windows)见 cv::String::deallocate()libopencv_java3.so :

$ nm -CD libopencv_java3.so | grep cv::String::deallocate
00000000003e3fa0 T cv::String::deallocate()
这意味着您的包装有问题 lib_opencv东西。让我们尝试使用 libopencv_java3.so 的真实绝对路径来测试它。 (从您的文件管理程序中复制它)并将其直接添加到 target_link_libraries(co_decoder_engine_android_lib ...)并为选定的 ABI 编译它。

关于android - 错误 : undefined reference to 'cv::String::deallocate()' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64265776/

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