[英]Compiling Android JNI for OpenCV on Mac OSX
Bear with me - this is a long description, but I wanted to include all details. 忍受我 - 这是一个很长的描述,但我想包括所有细节。 I'm trying use android NDK and JNI for building OpenCV Android apps.
我正在尝试使用Android NDK和JNI来构建OpenCV Android应用程序。
I'm following this tutorial to get everything installed: http://www.stanford.edu/class/ee368/Android/Tutorial-2-OpenCV-for-Android-Setup-Macintosh-API8.pdf 我正在按照本教程安装所有内容: http : //www.stanford.edu/class/ee368/Android/Tutorial-2-OpenCV-for-Android-Setup-Macintosh-API8.pdf
The following installed just fine: 以下安装就好了:
/usr/bin/g++
/usr/local/bin/swig
/usr/bin/cmake
/usr/bin/make
/Developer/pcre-8.32/
Contents of my .bashrc file: 我的.bashrc文件的内容:
export NDK=/Users/Me/Code/Android/android-ndk-r4-crystax
export SDK=/Users/Me/Code/Android/adt-bundle-mac-x86_64-20130219/
export OPCV=/Users/Me/Code/OpenCV/opencv
export PATH=$NDK:$SDK/tools:$SDK/platform-tools:$PATH
export NDK_ROOT=$NDK
Making OpenCV libraries went just fine. 使OpenCV库运行得很好。
Due to complaint in using make
, I had to make a small edit in /Users/Me/Code/OpenCV/opencv/android/android-jni/local.env.mk
which looked like so: 由于使用
make
投诉,我不得不在/Users/Me/Code/OpenCV/opencv/android/android-jni/local.env.mk
做一个小编辑,看起来像这样:
#ANDROID_NDK_ROOT=$(HOME)/android-ndk-r4-crystax
ANDROID_NDK_ROOT=/Users/Me/Code/Android/android-ndk-r4-crystax
Then upon trying again to make
in the android-jni, directory, disaster struck: 然后,在试图再次
make
在android-JNI,目录,灾难发生了:
/Users/Me/Code/Android/android-ndk-r4-crystax/ndk-build OPENCV_CONFIG=../build/android-opencv.mk \
PROJECT_PATH= ARM_TARGETS="armeabi armeabi-v7a" V=
Gdbserver : [arm-eabi-4.4.0] /Users/Me/Code/OpenCV/opencv/android/android-jni/libs/armeabi/gdbserver
Gdbsetup : /Users/Me/Code/OpenCV/opencv/android/android-jni/libs/armeabi/gdb.setup
Gdbsetup : + source directory /Users/Me/Code/OpenCV/opencv/android/android-jni/jni
Gdbserver : [arm-eabi-4.4.0] /Users/Me/Code/OpenCV/opencv/android/android-jni/libs/armeabi-v7a/gdbserver
Gdbsetup : /Users/Me/Code/OpenCV/opencv/android/android-jni/libs/armeabi-v7a/gdb.setup
Gdbsetup : + source directory /Users/Me/Code/OpenCV/opencv/android/android-jni/jni
SharedLibrary : libandroid-opencv.so
/Users/Me/Code/Android/android-ndk-r4-crystax/build/prebuilt/darwin-x86/arm-eabi-4.4.0/bin/../lib/gcc/arm-eabi/4.4.0/../../../../arm-eabi/bin/ld: cannot find -lopencv_calib3d
collect2: ld returned 1 exit status
make[1]: *** [/Users/Me/Code/OpenCV/opencv/android/android-jni/obj/local/armeabi/libandroid-opencv.so] Error 1
make: *** [libs/armeabi-v7a/libandroid-opencv.so] Error 2
I thought perhaps this was a pkg-config error, but that appears to be set up as well, though in my old install of OpenCV. 我想也许这是一个pkg-config错误,但似乎也设置了,虽然在我的旧版OpenCV中。 Below is the output of
pkg-config --cflags --libs opencv
: 下面是
pkg-config --cflags --libs opencv
的输出:
-I/usr/include/opencv /usr/lib/libopencv_calib3d.dylib /usr/lib/libopencv_contrib.dylib /usr/lib/libopencv_core.dylib /usr/lib/libopencv_features2d.dylib /usr/lib/libopencv_flann.dylib /usr/lib/libopencv_gpu.dylib /usr/lib/libopencv_highgui.dylib /usr/lib/libopencv_imgproc.dylib /usr/lib/libopencv_legacy.dylib /usr/lib/libopencv_ml.dylib /usr/lib/libopencv_nonfree.dylib /usr/lib/libopencv_objdetect.dylib /usr/lib/libopencv_photo.dylib /usr/lib/libopencv_stitching.dylib /usr/lib/libopencv_ts.dylib /usr/lib/libopencv_video.dylib /usr/lib/libopencv_videostab.dylib
The install built by this particular tutorial has placed an opencv.pc
file at this location: 此特定教程构建的安装在此位置放置了一个
opencv.pc
文件:
/Users/Me/Code/OpenCV/opencv/build/unix-install
BUT Running the below and trying make
again doesn't fix the problem: 但是运行下面并再次尝试
make
并不能解决问题:
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/Users/Me/Code/OpenCV/opencv/build/unix-install
I can't figure out what is wrong. 我无法弄清楚出了什么问题。 I've been battling with this problem for about a month on and off, and finally needed some outside opinions.
我一直在和这个问题争吵大约一个月,最后需要一些外界意见。 Any ideas?
有任何想法吗?
Error message says 错误信息说
cannot find -lopencv_calib3d collect2: ld returned 1 exit status
找不到-lopencv_calib3d collect2:ld返回1退出状态
It means linker can't find opencv_calib3d library. 这意味着链接器找不到opencv_calib3d库。 It may have name libopencv_calib3d.a or libopencv_calib3d.so.
它的名称可能是libopencv_calib3d.a或libopencv_calib3d.so。 So you need find one of them and add path to this file to your LD_LIBRARY_PATH env variable.
因此,您需要找到其中一个并将此文件的路径添加到LD_LIBRARY_PATH env变量中。
I mean if let's say folder /Users/Me/Code/OpenCV/opencv/lib contains libopencv_calib3d.so then you need execute something like following before make: 我的意思是如果让我们说文件夹/ Users / Me / Code / OpenCV / opencv / lib包含libopencv_calib3d.so那么你需要在make之前执行类似下面的事情:
export LD_LIBRARY_PATH=/Users/Me/Code/OpenCV/opencv/lib:$LD_LIBRARY_PATH
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.