我正在尝试为Android构建OpenCV 3.2。当我尝试为armeabi-v7a配置构建它时,编译它没有问题。但是,当我尝试为arm64-v8a硬件进行编译时,出现以下消息:
/Library/Android/sdk/ndk-bundle/platforms/android-21/arch-arm/usr/include/signal.h:87:12: error: expected ')'
void (*sa_sigaction)(int, struct siginfo*, void*);
^
/Library/Android/sdk/ndk-bundle/platforms/android-21/arch-arm/usr/include/asm/signal.h:102:24: note: expanded from macro 'sa_sigaction'
#define sa_sigaction _u._sa_sigaction
^
/Library/Android/sdk/ndk-bundle/platforms/android-21/arch-arm/usr/include/signal.h:87:10: note: to match this '('
void (*sa_sigaction)(int, struct siginfo*, void*);
^
/Library/Android/sdk/ndk-bundle/platforms/android-21/arch-arm/usr/include/signal.h:87:12: error: duplicate member '_u'
void (*sa_sigaction)(int, struct siginfo*, void*);
^
/Library/Android/sdk/ndk-bundle/platforms/android-21/arch-arm/usr/include/asm/signal.h:102:22: note: expanded from macro 'sa_sigaction'
#define sa_sigaction _u._sa_sigaction
^
/Library/Android/sdk/ndk-bundle/platforms/android-21/arch-arm/usr/include/signal.h:86:18: note: previous declaration is here
sighandler_t sa_handler;
^
/Library/Android/sdk/ndk-bundle/platforms/android-21/arch-arm/usr/include/asm/signal.h:101:20: note: expanded from macro 'sa_handler'
#define sa_handler _u._sa_handler
这是cmake的配置方式:
cmake -DCMAKE_TOOLCHAIN_FILE=$ANDROID_TOOLCHAIN -DANDROID_NDK=$NDK_ROOT -DANDROID_ABI=arm64-v8a -DANDROID_NATIVE_API_LEVEL=21 -DCMAKE_INSTALL_PREFIX=~/opencv/arm64 -DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF -DBUILD_TIFF=false -DTIFF_LIBRARY=$TIFF_LIBRARY -DTIFF_INCLUDE_DIR=$TIFF_INCLUDE_DIR -DBUILD_OPENEXR=false
还有其他人遇到过这个问题吗?我已经努力了两天了。任何帮助将不胜感激。
编辑:我注意到cmake输出以下行:
Target: Android 21 armv7-a
即使我将abi设置为arm64-v8a。有什么想法吗?
最佳答案
希望你解决了这个问题。
当我先使用cmake-gui,然后分配工具链文件时,我也遇到了这个问题。
我解决了这个问题,只用
cmake .. -DCMAKE_TOOLCHAIN_FILE=$NDK_PATH/build/cmake/android.toolchain.cmake -DANDROID_ABI="arm64-v8a"
然后使用cmake-gui设置构建子系统。那一切都会好起来的。