compiling opencv for Java

1. 参考文档

install in linux and mac
http://docs.opencv.org/2.4/doc/tutorials/introduction/linux_install/linux_install.html
java
http://docs.opencv.org/2.4/doc/tutorials/introduction/desktop_java/java_dev_intro.html
http://docs.opencv.org/trunk/d7/d9f/tutorial_linux_install.html

2. linux编译要点

cmake配置

cmake -D CMAKE_BUILD_TYPE=RELEASE \
    -D CMAKE_INSTALL_PREFIX=/home/yu/.programs/opencv \
    -DBUILD_SHARED_LIBS=OFF \
    BUILD_EXAMPLES=OFF \
    BUILD_TESTS=OFF \
    BUILD_PERF_TESTS=OFF ..

编译安装

make -j32
make install

为动态库配置路径

opencv: pkg-config

export PKG_CONFIG_PATH=/home/yu/.programs/opencv/lib/pkgconfig

opencv: dylib

export LD_LIBRARY_PATH=/home/yu/.programs/opencv/share/OpenCV/java

3. mac编译要点

cmake配置

cmake -D CMAKE_BUILD_TYPE=RELEASE -D \
    CMAKE_INSTALL_PREFIX=/Users/yu/.programs/opencv/ \
    -DBUILD_SHARED_LIBS=OFF ..

编译安装

make -j32
make install

安装后只有一个dylib: ./share/OpenCV/java/libopencv_java320.dylib, 其余都为.a

配置路径

opencv: pkg-config

export PKG_CONFIG_PATH=/Users/yu/.programs/opencv/lib/pkgconfig/

opencv: dylib

export DYLD_LIBRARY_PATH=/Users/yu/.programs/opencv/share/OpenCV/java