Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » How to use native lib in an Eclipse RCP App. (Bundling OpenCV)
How to use native lib in an Eclipse RCP App. (Bundling OpenCV) [message #1722295] Wed, 03 February 2016 20:27 Go to next message
frank b is currently offline frank bFriend
Messages: 45
Registered: July 2009
Member
Hello,

I want to use opencv library with its native library in my RCP App. Everything is fine if I add the jar lib in plugin class path using Build Path -> Configure Build Path... etc. and specifying the native library for this jar lib.

Another possibility (the one that I would like to use) is to create a plugin from this jar lib using "create new plugin from external jar archive" and to add Bundle-NativeCode directive to Manifest.MF. Something like that :

Bundle-NativeCode: nativeLibs/libopencv_java300.dylib; osname=MacOSX; processor=x86-64

Then, in the RCP App., I first remove everything from class path and, without changing anything in source code, add this new plugin in plugin dependencies of the RCP App.

Now, when I run the App., opencv library seems to not be correctly loaded (using System.LoadLibrary()) as I have this error message :

org.eclipse.e4.core.di.InjectionException: java.lang.UnsatisfiedLinkError: no opencv_java300 in java.library.path

I've been looking on internet to find an answer but without success. I have missed something but what ?

Please could you help me ?

Thanks a lot,
frank

PS : Everything is done using eclipse-RCP-4.4.2, mac OS X.9.5 and OpenCV 3.0 (OpenCV lib has been compiled on the computer)

[Updated on: Wed, 03 February 2016 22:06]

Report message to a moderator

Re: How to use native lib in an Eclipse RCP App. (Bundling OpenCV) [message #1722304 is a reply to message #1722295] Thu, 04 February 2016 00:51 Go to previous messageGo to next message
Eclipse UserFriend
Your os and processor are wrong -- at least, they won't match OS X. You want

Bundle-NativeCode: nativeLibs/libopencv_java300.dylib; osname=macosx; processor=x86_64


I documented a few gotchas a while back.
Re: How to use native lib in an Eclipse RCP App. (Bundling OpenCV) [message #1722318 is a reply to message #1722304] Thu, 04 February 2016 07:27 Go to previous messageGo to next message
frank b is currently offline frank bFriend
Messages: 45
Registered: July 2009
Member
Brian,

thank you for your reply.

I've made changes you suggest but it unfortunately did not solve the problem.

Still this same java.lang.UnsatisfiedLinkError Mad
Re: How to use native lib in an Eclipse RCP App. (Bundling OpenCV) [message #1722390 is a reply to message #1722318] Thu, 04 February 2016 14:23 Go to previous messageGo to next message
Eclipse UserFriend
So a few other things spring to mind:

Check if this library has other dependencies with 'otool -L libopencv_java300.dylib'. The JVM doesn't load dependencies automatically, and the dynamic linker won't unless those dependencies are found on your linker path. If they're also part of your bundle, you have to make sure you load them first.

The other possibility: are you sure you've included the DLL in your bundle? It actually sounds like the file wasn't found rather than an error when resolving the DLL.

Brian.
Re: How to use native lib in an Eclipse RCP App. (Bundling OpenCV) [message #1722401 is a reply to message #1722390] Thu, 04 February 2016 15:23 Go to previous messageGo to next message
frank b is currently offline frank bFriend
Messages: 45
Registered: July 2009
Member
Here is the output of the otool command :

iMac-de-Frank:OpenCV_JAR frank$ otool -L libopencv_java300.dylib
libopencv_java300.dylib:
/Users/frank/OPENCV/SharedLibraries/lib/libopencv_java300.dylib (compatibility version 0.0.0, current version 0.0.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.0.0)
/System/Library/Frameworks/OpenCL.framework/Versions/A/OpenCL (compatibility version 1.0.0, current version 1.0.0)
/System/Library/Frameworks/QTKit.framework/Versions/A/QTKit (compatibility version 1.0.0, current version 1.0.0)
/System/Library/Frameworks/QuartzCore.framework/Versions/A/QuartzCore (compatibility version 1.2.0, current version 1.8.0)
/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 1265.21.0)
/System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 20.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1197.1.1)
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 855.17.0)
/System/Library/Frameworks/CoreVideo.framework/Versions/A/CoreVideo (compatibility version 1.2.0, current version 1.8.0)
/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 1056.17.0)
/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)

Don't see any missing lib or any version incompatibility Confused

Quote:
are you sure you've included the DLL in your bundle? It actually sounds like the file wasn't found rather than an error when resolving the DLL.


What do you mean ?

opencv Jar and dylib files are in the root folder plugin. The jar file is added to the class path of the plugin and there is the Bundle-NativeCode directive.

I've not exported the plugin as a jar. I just test my RCP app. with a dependency link to this previous plugin. Must I do anything else to include the DLL ?

If you have any other ideas... you are welcome Smile

Thanks.
Re: How to use native lib in an Eclipse RCP App. (Bundling OpenCV) [message #1722406 is a reply to message #1722401] Thu, 04 February 2016 16:00 Go to previous messageGo to next message
Eclipse UserFriend
frank b wrote on Thu, 04 February 2016 10:23

iMac-de-Frank:OpenCV_JAR frank$ otool -L libopencv_java300.dylib
libopencv_java300.dylib:
/Users/frank/OPENCV/SharedLibraries/lib/libopencv_java300.dylib (compatibility version 0.0.0, current version 0.0.0)
...

If I'm reading this right, you're in an OpenCV_JAR directory? That's not your bundle? Note that otool/dyld is loading another libopencv_java300.dylib (weird) from /Users/frank/OPENCV/SharedLibraries/lib/ which is is not a standard directory/ Do you have /Users/frank/OPENCV/SharedLibraries/lib/ on your DYLD_LIBRARY_PATH?

(It also seems strange that libopencv_java300.dylib includes a same-named .dylib.)

Quote:

opencv Jar and dylib files are in the root folder plugin. The jar file is added to the class path of the plugin and there is the Bundle-NativeCode directive.

I've not exported the plugin as a jar. I just test my RCP app. with a dependency link to this previous plugin. Must I do anything else to include the DLL ?


I'm confused as to what you mean by "in the root folder plugin". Could you give a file listing of your bundle?

But perhaps instead of trying to diagnose this via email/forum, here's a known-to-work bundle that uses Bundle-NativeCode. Take a look and compare and contrast to your own. Note the build.properties needs to include the DLL location.

https://github.com/briandealwis/jmapi

Brian.
Re: How to use native lib in an Eclipse RCP App. (Bundling OpenCV) [message #1722428 is a reply to message #1722406] Thu, 04 February 2016 18:47 Go to previous message
frank b is currently offline frank bFriend
Messages: 45
Registered: July 2009
Member
Brian,

Quote:

iMac-de-Frank:OpenCV_JAR frank$ otool -L libopencv_java300.dylib
libopencv_java300.dylib:
/Users/frank/OPENCV/SharedLibraries/lib/libopencv_java300.dylib (compatibility version 0.0.0, current version 0.0.0)


yes it's like if the lib was needing itself... I didnt see that. It comes from the folder where I compiled OpenCV. How can it be possible ? I have to look at this compile process... Anyway why would it works when I use this lib with traditional class path ???? Don't think the problem is here. This lib is not in DYLD_LIBRARY_PATH.

EDIT -> otool -L displays also a kind of ID of the dylib itself always at the first line. It is not actually a circular link. I've checked that with other libraries from osx system.

Here is a list of what is displayed under OpenCV_JAR plugin folder in Package Explorer View :

JRE Sys. Lib.
Plug-in Dep.
Ref. Libs.
META-INF
build.properties
libopencv_java300.dylib
opencv-300.jar


Thanks a lot for the link to jmapi,
frank

[Updated on: Thu, 04 February 2016 20:17]

Report message to a moderator

Previous Topic:CDATA in Extension Point Schema (.exsd file)
Next Topic:Styling menus and buttons
Goto Forum:
  


Current Time: Tue Apr 23 17:51:35 GMT 2024

Powered by FUDForum. Page generated in 0.04548 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top