This problem has set me back 2 straight days and I am getting very desperate at this point. As the question description states I need the OpenCV 2.4.11 java library 32 bit version that will run with JDK 1.6 on a Mac running Yosemite.
I require this because another library that I am using requires 32 bit (and this is only available with JDK 1.6). Hence I am using JDK 1.6 and passing the VM argument -d32
.
I have had two main attempts:
For both attempts I first set my default JDK to 6:
$nano .bash_profile //Opening the Bash Profile
export JAVA_HOME=$(/usr/libexec/java_home -v 1.6) //Set Java_Home to JDK 1.6
(It is to be noted that both methods below have no problems building the library with JDK 1.7 and 64bit.)
Method 1: I try and build the OpenCV library with CMake:
I go to the directory where I saved the library
mkdir build //Create a build directory
cd build //Go the build directory
cmake -G "Unix Makefiles" -D CMAKE_OSX_ARCHITECTURES=i386 -D CMAKE_C_FLAGS=-m32 -D CMAKE_CXX_FLAGS=-m32 ..
(I found this method from this thread)
The journey of this attempt ends here because there is a problem with linking the Java components:
-- Could NOT find JNI (missing: JAVA_AWT_LIBRARY JAVA_JVM_LIBRARY JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2 JAVA_AWT_INCLUDE_PATH)
and
-- Java:
-- ant: /usr/local/bin/ant (ver 1.9.6)
-- JNI: NO
-- Java tests: NO
The complete output can be found here.
It turns out that this is some issue with CMake and I tried the suggestions from this thread. Modifying FindJNI.cmake
did not solve the problem.
Method 2 I try and build the OpenCV library with HomeBrew:
brew tap homebrew/science
brew install opencv --with-java --universal
The build goes fine. Once I locate the .jar
and .dylib
and create the OpenCV library in Eclipse and run the project I get the following error:
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/opencv/core/Point : Unsupported major.minor version 51.0
Which means that it did not build with JDK 1.6.
Other thoughts/Attempts:
- Try the methods on other computers. I had to stop because I ran into trouble setting up cmake and homebrew because the computers where not set up as "developer" computers i.e They did not have Git, XCode etc.
- Using JDK 1.5. Turns out JDK is not supported on Yosemite but I found this thread how I could try get it up and running.
- Try using an earlier version of OpenCV. I tried version 2.4.10 but ran into the same issues.