Quantcast
Channel: Sam的技术Blog
Viewing all articles
Browse latest Browse all 158

OpenCV4Android编译

$
0
0
作者: Sam (甄峰)  sam_code@hotmail.com

又尝试完整编译OpenCV4Android (3.1), 因为开发平台(FC26-64bit), CMake(3.9.1), Android SDK 版本,NDK(ndk R14B)等都有变化,会遇到一些版本匹配问题。现记录如下。

编译方法,与之前的blog(http://blog.sina.com.cn/s/blog_602f87700102vdnw.html)一样。

A:先建立配置脚本:
32bit: 
export ANDROID_NDK=/opt/android-ndk-r14b/
export ANDROID_SDK=/home/sam/Android/Sdk
export ANDROID_ABI=armeabi-v7a

export ANT_HOME=/usr/share/ant
export PATH=${PATH}:${ANT_HOME}/bin

B:开始配置:
$source setenv_32bit
$cd platforms
$sh scripts/cmake_android_arm.sh

C: 开始编译:
$cd build_android_arm
$make 
或为了能看到更多编译细节,而使用:
$make VERBOSE=1

错误一:
会报错如下:
*************************************************************************
The "android" command is deprecated.
For manual SDK, AVD, and project management, please use Android Studio.
For command-line tools, use tools/bin/sdkmanager and tools/bin/avdmanager
*************************************************************************

因为新版本Android SDK中,Tools目录内,android命令已经废弃。 
从OpenCV 这端修改太麻烦。所以干脆把之前老版本的Android  SDK copy一份,并设置ANDROID_SDK指向这个目录:
export ANDROID_SDK=/home/sam/Android/android-sdk-linux

删除build_android_arm目录,重新来一次。


错误二:
/opt/android-ndk-r14b/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc -fPIC -fexceptions -frtti -fpic -Wno-psabi --sysroot=/opt/android-ndk-r14b/platforms/android-14/arch-arm -funwind-tables -finline-limit=64 -fsigned-char -no-canonical-prefixes -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -fdata-sections -ffunction-sections -Wa,--noexecstack    -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security  -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -fdiagnostics-show-option -fomit-frame-pointer -fvisibility=hidden -fvisibility-inlines-hidden -Wno-missing-declarations -mthumb -fomit-frame-pointer -fno-strict-aliasing -O3 -DNDEBUG  -DNDEBUG  -Wl,--fix-cortex-a8 -Wl,--no-undefined -Wl,-allow-shlib-undefined -Wl,--gc-sections -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now  -shared -Wl,-soname, -o .build/libs/armeabi-v7a/libdetection_based_tracker.so CMakeFiles/detection_based_tracker.dir/jni/DetectionBasedTracker_jni.cpp.o  -L/home/sam/work/current/Research/OpenCV/opencv-3.1.0/platforms/build_android_arm/install/libs/armeabi-v7a -ldl -lm -llog ../../../lib/armeabi-v7a/libopencv_java3.so -ldl -lm -llog -ljnigraphics  "/opt/android-ndk-r14b/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/libgnustl_static.a" "/opt/android-ndk-r14b/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/libsupc++.a" -lm


/opt/android-ndk-r14b/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: fatal error: -soname: must take a non-empty argument

cmake3.2开始,就在NO_SONAME上与之前有所不同, 它的NO_SONAME property 缺省被Enable。但它会引发与
 

Viewing all articles
Browse latest Browse all 158

Trending Articles