为Mac构建OpenCV JDK 6 32位 [英] Build OpenCV JDK 6 32 bit for Mac
问题描述
这个问题使我连续两天退缩,这时我感到非常绝望.正如问题描述所述,我需要32位版本的OpenCV 2.4.11 Java库,它将在运行优胜美地的Mac上与JDK 1.6一起运行.
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
.
我做了两次主要尝试:
对于这两次尝试,我首先将默认的JDK设置为6:
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
(请注意,以下两种方法在使用JDK 1.7和64位构建库时都没有问题.)
方法1: 我尝试使用CMake构建OpenCV库:
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 ..
(我从 this 线程中找到了此方法)
(I found this method from this thread)
此尝试的旅程到此结束,因为链接Java组件存在问题:
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)
和
-- 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.
方法2 我尝试使用HomeBrew构建OpenCV库:
Method 2 I try and build the OpenCV library with HomeBrew:
brew tap homebrew/science
brew install opencv --with-java --universal
构建正常.找到.jar
和.dylib
并在Eclipse中创建OpenCV库并运行项目后,出现以下错误:
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
这意味着它不是使用JDK 1.6构建的.
Which means that it did not build with JDK 1.6.
其他想法/尝试:
Other thoughts/Attempts:
- 在其他计算机上尝试这些方法.我不得不停下来,因为我 设置cmake和自制软件时遇到麻烦,因为计算机 没有设置为开发者"计算机的地方,即他们没有Git, XCode等.
- 使用JDK 1.5.事实证明,优胜美地不支持JDK,但我发现 此线程我如何尝试将其启动并正在运行.
- 尝试使用早期版本的OpenCV.我尝试了2.4.10版,但 遇到了同样的问题.
- 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.
推荐答案
您可以做的是运行两个程序. 1个32位和1个64位.每个人都通过TCP与对方对话套接字,RMI,消息传递.
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.
这样,您可以同时使用32位和64位库.
This way you can use a 32-bit and a 64-bit library at the same time.
这篇关于为Mac构建OpenCV JDK 6 32位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!