gpt4 book ai didi

android - CMake设置目标属性使用错误的参数数量调用

转载 作者:行者123 更新时间:2023-12-02 10:23:08 24 4
gpt4 key购买 nike

我正在尝试在项目中使用 OpenCV 库,但是在运行时出现此错误:

Build command failed. Error while executing process D:\Sdk\cmake\3.6.4111459\bin\cmake.exe with arguments {-HC:\Users\Mouad AITALI\AndroidStudioProjects\BGREMOVER\app -BC:\Users\Mouad AITALI\AndroidStudioProjects\BGREMOVER\app.cxx\cmake\debug\arm64-v8a -DANDROID_ABI=arm64-v8a -DANDROID_PLATFORM=android-16 -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\Mouad AITALI\AndroidStudioProjects\BGREMOVER\app\build\intermediates\cmake\debug\obj\arm64-v8a -DCMAKE_BUILD_TYPE=Debug -DANDROID_NDK=D:\Sdk\ndk\19.2.5345600 -DCMAKE_CXX_FLAGS=-std=c++11 -DCMAKE_TOOLCHAIN_FILE=D:\Sdk\ndk\19.2.5345600\build\cmake\android.toolchain.cmake -DCMAKE_MAKE_PROGRAM=D:\Sdk\cmake\3.6.4111459\bin\ninja.exe -GAndroid Gradle - Ninja} -- Configuring incomplete, errors occurred! See also "C:/Users/Mouad AITALI/AndroidStudioProjects/BGREMOVER/app/.cxx/cmake/debug/arm64-v8a/CMakeFiles/CMakeOutput.log".

CMake Error at CMakeLists.txt:13 (set_target_properties):
set_target_properties called with incorrect number of arguments.



CMakeLists.txt
#declare folder path
set(pathToProject C:\\Users\\Mouad;AITALI\\AndroidStudioProjects\\BGREMOVER)

cmake_minimum_required(VERSION 3.4.1)

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

include_directories(${pathToOpenCv}/sdk/native/jni/include)

#library location
add_library(lib_opencv SHARED IMPORTED)
set_target_properties(lib_opencv PROPERTIES IMPORTED_LOCATION ${pathToProject}/app/src/main/jniLibs/${ANDROID_ABI}/libopencv_java3.so)

#define libraries
add_library(native-lib SHARED src/main/cpp/native-lib.cpp)
add_library(grabcut SHARED src/main/cpp/jni-grabcut-lib.cpp src/main/cpp/grabcutter_p.cpp src/main/cpp/grabcutter_p.h)

find_library(log-lib log)

#target libraries
target_link_libraries(native-lib ${log-lib} lib_opencv)
target_link_libraries(grabcut ${log-lib} lib_opencv)

最佳答案

如前所述,CMake使用分号;定义列表。因此,如果路径包含分号,则必须将定义括起来,并在使用双引号的变量pathToProject处放置:

set(pathToProject "C:\\Users\\Mouad;AITALI\\AndroidStudioProjects\\BGREMOVER")

...

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

IMPORTED_LOCATION 属性只有一个值。因此,当您提供该属性的列表时, set_target_properties()命令无法正确解析参数,从而产生错误。

关于android - CMake设置目标属性使用错误的参数数量调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59185478/

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