Link to home
Start Free TrialLog in
Avatar of TristanTheHakSoar
TristanTheHakSoar

asked on

com.googlecode.javacv not working

Hey all,

I have been trying desperately to get javacv working on my MacBook 10.6.8 64-bit without any luck.

I followed the following quickstart guide: http://code.google.com/p/javacv/

I want to use eclipse to do this, but unfortunately i get the following error:
Exception in thread "main" java.lang.UnsatisfiedLinkError:
/private/var/folders/LB/LB61BZtPFq4LULxHfE3xPE+++TI/-Tmp-/libjniopencv_core6616875771379943551.dylib:  
Library not loaded: lib/libopencv_core.2.4.dylib  
Referenced from: /private/var/folders/LB/LB61BZtPFq4LULxHfE3xPE+++TI/-Tmp-/libjniopencv_core6616875771379943551.dylib  
Reason: image not found

I have tried dumping libopencv_core.2.4.dylib into every lib folder on my system with no luck and have tried changing the following variable in configurations.
DYLD_FALLBACK_LIBRARY_PATH
which i have set to:
/usr/local/lib
and
opt/local/lib
and various other lib directories i have placed the .dylib file into.

I have moved onto compiling on the command line providing the classpath to the jar files via the -cp option and the class compiles, but when i try to run i get the error:

Exception in thread "main" java.lang.NoClassDefFoundError: MotionDetector

So i pulled all the code out of motion detector except for a single print statement that would tell me the classpath "System.out.println(System.getProperty("java.classpath"))" and i still get the error which leads me to believe that the imports are causing the problem.

import com.googlecode.javacpp.Loader;
import com.googlecode.javacv.*;
import static com.googlecode.javacv.cpp.opencv_core.*;
import static com.googlecode.javacv.cpp.opencv_imgproc.*;
import static com.googlecode.javacv.cpp.opencv_calib3d.*;
import static com.googlecode.javacv.cpp.opencv_objdetect.*;

I compile and run with commands like:
javac -cp ../javacv.jar:../javacpp.jar MotionDetector.java
java -cp ../javacv.jar:../javacpp.jar MotionDetector

I have searched the internet for days now trying to find the correct way to include the googlecode into my classpath or on my system but haven't found any, i did follow a tutorial that installed the google plugin into eclipse so i figure it should be there, any help would be hugely appreciated.

- Tristan
MotionDetector2.java
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Avatar of TristanTheHakSoar
TristanTheHakSoar

ASKER

In eclipse and on the command line the java.library.path returned is:

:/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java

the first contains the files librxtxSerial.jnilib and RXTXcomm.jar

the second has a number of other jar and jnilib files

the last contains libjdns_sd.jnilib

neither of these are the path to the javacv jar files i included as external jars in the project if that helps.
neither of these are the path to the javacv jar files i included as external jars in the project if that helps.


The important thing is that the native libraries must be in one of those directories. The classpath is another issue, and of course your jars must be in that
he classpath is another issue, and of course your jars must be in that

I have noticed that on printing "java.classpath" it returns null, might this be the problem? I had assumed that my settings in the eclipse run/debug configuration merged the locations of those jar files with the classpath but perhaps I am mistaken, i will dig around a little more on those settings and try to get back with a success unless you come back with a better idea.

Also i decided that it would be a good idea to check the bitness of everything and all my librairies as well as eclipse are 64 so no problem there it seems.

I've also checked to make sure that I have the google app engine properly installed and it seems to be a part of my project, any way I can detect this or the jar files in my eclipse classpath? There are no errors that eclipse picks up and I am able to use all of the objects in the libraries, it is just the compilation that fails returning null pointers for whatever objects i try to create.
I have noticed that on printing "java.classpath" it returns null, might this be the problem?

No. That property doesn't exist. It's

System.out.println(System.getProperty("java.class.path"));

Open in new window

ah kk, so i tried that and got the path this time with all the necessary jars included, i don't see a link to the opencv_core.2.4.dylib file though it probably shouldn't be in here?

I have gone into /opt/local/lib/ and found the following files:

libopencv_core.2.4.0.dylib
libopencv_core.2.4.dylib -> libopencv_core.2.4.0.dylib
libopencv_core.dylib -> libopencv_core.2.4.dylib

i did the opencv through macports so i assume these links should be working correctly, perhaps i should try to uninstall and reinstall the port?
well that didnt work either, perhaps the way to go would be to implement in c++ and use a java wrapper for that.

anyone out there got javacv to run?
ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
As mentioned above I have tried to set the environment variable DYLD_FALLBACK_LIBRARY_PATH with the value: ${env_var:/opt/local/lib/} but there are other variable types to choose from, perhaps I am using the wrong one?
That's not the point i made. I'm talking about java.library.path
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
:)
because it explains why it did not work in the first place, though the points go to who pointed to the right place