Tag Archives: eclipse

Building and using OpenCV with Eclipse on Mac OS X

This took me a little while to figure out due to the sometimes subtle differences in Mac OS X and Linux, and the imperfect documentation.  Eventually I got it working though. The goal was to build OpenCV for Mac OS X 10.9 and then get it working in Eclipse. So, here goes:

  1. Ensure you’re using a JDK with version number 1.7 or higher.  If not, see here for instructions.
  2. Download the latest version of OpenCV (I used 2.4.8, so if you have problems, try going back this) from here, for Mac.
  3. Extract it.
  4. cd into the extracted directory of OpenCV in your terminal and execute the following:
mkdir build
cd build
cmake -G "Unix Makefiles" -D CMAKE_CXX_COMPILER=/usr/bin/g++ -D CMAKE_C_COMPILER=/usr/bin/gcc -D WITH_CUDA=ON ..
make -j2

(Note in the above, -j2 refers to the number of CPU cores I had – e.g. set to -j4 if you have 4 logical cores).

Then just look in build/bin, and you’ll see a .jar at the bottom – congratulations, you just built OpenCV! Import this as a library into Eclipse, and set the native path also to build/bin, and you’re done.

If you get stuck, let me know in the comments and I’ll do my best to help.

Installing JRE {7,8} / JDK {1.7,1.8} On Mac for Eclipse

As part of my Software Engineering Project (SEPR) for my course, I’m working on a game with my teammates in Java.  Unfortunately, even with the latest release of OS X (10.9.2), Apple still only provide you with the JDK V1.6, which is quite old and lacks some commonly used features from 1.7 and 1.8.  Although installing it isn’t exactly complicated, it’s not obvious how to link it into your system, and I couldn’t find a manual for doing this with Eclipse.

Now that I’ve found out how to do it, it makes sense to share it to potentially save you some time:

  • Download the latest version (JRE 8, JDK 1.8 at the time of writing) from here.
  • Install it – it should install automatically to a path similar to:
/Library/Java/JavaVirtualMachines/jdk1.8.0_<more numbers>.jdk/Contents/Home
Note, the above scrolls, it ends with '/Home'
  • Open Eclipse, and in the top menu go to Preferences->Java->Installed JRE’s-> and click the add button.
  • Then select “Standard VM” and click next.  Give it the install path from above for the “JRE Home” parameter and click Finish.  Now you can select the new upgraded JRE/JDK for your projects in Eclipse.

I hope that helps.