1

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.
Community
  • 1
  • 1
Luke Taylor
  • 9,481
  • 13
  • 41
  • 73
  • 1
    I know it's not cheap, but you might need to update. – Peter Lawrey Dec 05 '15 at 10:30
  • 1
    Installing the latest [Java 6 JDK from Apple](https://support.apple.com/kb/dl1572?locale=en_US) resolved a different, long-standing 32-bit library problem for me. For reference, I'm seeing `build 1.6.0_65-b14-468-11M4833`. – trashgod Dec 05 '15 at 10:46
  • @PeterLawrey update what? – Luke Taylor Dec 05 '15 at 11:27
  • @trashgod Thank you I will try that! (I might have installed that version though) – Luke Taylor Dec 05 '15 at 11:28
  • Looks like a very specific problem, that is not well suited here. OpenCV is unrelated. Just ask how to find Java 1.6 with 32 bit using OS X. Or do as Peter suggested and update whatever library you need to one that does not require 32bit Java. – usr1234567 Dec 05 '15 at 13:11
  • @PeterLawrey If you are referring to the other library, it cannot run in 64 bit. http://www.lejos.org/nxt/nxj/tutorial/Preliminaries/GettingStartedWindows.htm – Luke Taylor Dec 05 '15 at 14:07

1 Answers1

0

What you can do is have two program running. One 32-bit and one 64-bit. Each talks to the other via TCP e.g. SOcket, RMI, Messaging.

This way you can use a 32-bit and a 64-bit library at the same time.

Peter Lawrey
  • 525,659
  • 79
  • 751
  • 1,130
  • 1
    Hey Peter, I was considering this an option but I think it would be too slow. Thank god I managed to finally crack this problem (it was slowly driving me crazy), I'll write a blog post on how I managed to do it for any poor soul out there that is undergoing the same issue. It turned out that modifying the FindJNI.cmake file solved it (I must have done something wrong the first time I attempted this). – Luke Taylor Dec 05 '15 at 22:01
  • Thank you for you help though :) – Luke Taylor Dec 05 '15 at 22:01
  • 1
    @LukeTaylor it is easier if you don't need to do this but you should be able to get 1 GB/s and a 30 micro-second latency between processes on a Mac fairly easily. – Peter Lawrey Dec 05 '15 at 22:14