在我们的应用程序中要集成OpenCV c / c ++库。我已经成功集成了OpenCV库,但是当尝试使用android NDK r12b进行构建时,出现以下构建错误。
Build command failed.
Error while executing process C:\Users\Dell\AppData\Local\Android\Sdk\cmake\3.10.2.4988404\bin\cmake.exe with arguments {--build D:\Project\WorkSpace\AndroidStudio\Sample\Sample2NativeSample\app\.externalNativeBuild\cmake\debug\x86 --target native-lib}
[0/1] Re-running CMake...
-- Configuring done
-- Generating done
-- Build files have been written to: D:/Project/WorkSpace/AndroidStudio/Sample/Sample2NativeSample/app/.externalNativeBuild/cmake/debug/x86
[1/150] Building CXX object CMakeFiles/native-lib.dir/src/features/RVUPHistogramFeature.cpp.o
FAILED: CMakeFiles/native-lib.dir/src/features/RVUPHistogramFeature.cpp.o
D:\Project\Android\android-ndk-r12b\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++.exe -target i686-none-linux-android -gcc-toolchain D:/Project/Android/android-ndk-r12b/toolchains/x86-4.9/prebuilt/windows-x86_64 --sysroot=D:/Project/Android/android-ndk-r12b/platforms/android-15/arch-x86 -Dnative_lib_EXPORTS -ID:/Project/WorkSpace/AndroidStudio/Sample/Sample2NativeSample/app/src/main/cpp/include/algorithm -ID:/Project/WorkSpace/AndroidStudio/Sample/Sample2NativeSample/app/src/main/cpp/include/deps/msvc/sys -ID:/Project/WorkSpace/AndroidStudio/Sample/Sample2NativeSample/app/src/main/cpp/include/features -ID:/Project/WorkSpace/AndroidStudio/Sample/Sample2NativeSample/app/src/main/cpp/include/opencv -ID:/Project/WorkSpace/AndroidStudio/Sample/Sample2NativeSample/app/src/main/cpp/include/opencv2/imgproc -ID:/Project/WorkSpace/AndroidStudio/Sample/Sample2NativeSample/app/src/main/cpp/include/opencv2/core -ID:/Project/WorkSpace/AndroidStudio/Sample/Sample2NativeSample/app/src/main/cpp/include/opencv2/ml -ID:/Project/WorkSpace/AndroidStudio/Sample/Sample2NativeSample/app/src/main/cpp/include/opencv2 -ID:/Project/WorkSpace/AndroidStudio/Sample/Sample2NativeSample/app/src/main/cpp/include/prediction -ID:/Project/WorkSpace/AndroidStudio/Sample/Sample2NativeSample/app/src/main/cpp/include/wsq -ID:/Project/WorkSpace/AndroidStudio/Sample/Sample2NativeSample/app/src/main/cpp/include -isystem D:/Project/Android/android-ndk-r12b/sources/cxx-stl/gnu-libstdc++/4.9/include -isystem D:/Project/Android/android-ndk-r12b/sources/cxx-stl/gnu-libstdc++/4.9/libs/x86/include -isystem D:/Project/Android/android-ndk-r12b/sources/cxx-stl/gnu-libstdc++/4.9/include/backward -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -Wa,--noexecstack -Wformat -Werror=format-security -fno-exceptions -fno-rtti -fexceptions -frtti -frtti -fexceptions -O0 -fno-limit-debug-info -fPIC -MD -MT CMakeFiles/native-lib.dir/src/features/RVUPHistogramFeature.cpp.o -MF CMakeFiles\native-lib.dir\src\features\RVUPHistogramFeature.cpp.o.d -o CMakeFiles/native-lib.dir/src/features/RVUPHistogramFeature.cpp.o -c D:/Project/WorkSpace/AndroidStudio/Sample/Sample2NativeSample/app/src/main/cpp/src/features/RVUPHistogramFeature.cpp
In file included from D:/Project/WorkSpace/AndroidStudio/Sample/Sample2NativeSample/app/src/main/cpp/src/features/RVUPHistogramFeature.cpp:1:
In file included from D:/Project/WorkSpace/AndroidStudio/Sample/Sample2NativeSample/app/src/main/cpp/include/features\RVUPHistogramFeature.h:4:
D:/Project/Android/android-ndk-r12b/platforms/android-15/arch-x86/usr/include\stdio.h:257:37: `*error: unknown type name '__va_list'; did you mean 'va_list'?*`
int vfprintf(FILE *, const char *, __va_list);
^
D:\Project\Android\android-ndk-r12b\toolchains\llvm\prebuilt\windows-x86_64\bin\..\lib64\clang\3.8.256229\include\stdarg.h:30:27: note: 'va_list' declared here
typedef __builtin_va_list va_list;
在这里,检查我的CMakeLists.txt
cmake_minimum_required(VERSION 3.4.1)
include_directories(include/algorithm
include/deps/msvc/sys
include/features
include/opencv
include/opencv2/imgproc
include/opencv2/core
include/opencv2/ml
include/opencv2
include/prediction
include)
file(GLOB_RECURSE SOURCES
"src/features/*.cpp"
"src/opencv/core/*.cpp"
"src/opencv/core/*.hpp"
"src/opencv/imgproc/*.cpp"
"src/opencv/imgproc/*.h"
"src/opencv/ml/*.cpp"
"src/opencv/ml/*.hpp"
"src/prediction/*.cpp"
"src/*.cpp"
"src/*.c")
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).
native-lib.cpp
${SOURCES})
find_library( # Sets the name of the path variable.
log-lib
log)
find_package(ZLIB)
target_link_libraries( # Specifies the target library.
native-lib
${log-lib}
${ZLIB_LIBRARIES})
还要检查我的gradle cmake声明。
externalNativeBuild {
cmake {
cppFlags "-frtti -fexceptions"
arguments '-DANDROID_TOOLCHAIN=clang',
'-DANDROID_STL=gnustl_static',
'-DANDROID_CPP_FEATURES=exceptions rtti',
'-DLOCAL_ALLOW_UNDEFINED_SYMBOLS = true'
abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
}
}
我尝试了许多解决方案,也尝试使用最新的NDK r20,但仍然收到此错误。我该如何解决这个错误?
答案 0 :(得分:-1)
这是特定于编译器的东西。
据我所知,大多数编译器都会使用va_list
。