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
JavaMac OS XPhotos / Graphics Software

Avatar of undefined
Last Comment
TristanTheHakSoar

8/22/2022 - Mon
CEHJ

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.
CEHJ

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
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
TristanTheHakSoar

ASKER
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.
CEHJ

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

TristanTheHakSoar

ASKER
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?
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
TristanTheHakSoar

ASKER
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
CEHJ

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
TristanTheHakSoar

ASKER
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?
CEHJ

That's not the point i made. I'm talking about java.library.path
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
CEHJ

:)
TristanTheHakSoar

ASKER
because it explains why it did not work in the first place, though the points go to who pointed to the right place