Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Eclipse 4 and native code
Eclipse 4 and native code [message #1021593] Wed, 20 March 2013 11:09 Go to next message
Dirk Fauth is currently offline Dirk Fauth
Messages: 1267
Registered: July 2012
Senior Member
Hi,

I am trying to use native code in my Eclipse 4 app. I read several wikis and blogs but I can't get it to work. The issue is that the native code has dependencies to other native code and it isn't resolved by Eclipse.

What I have done so far is to create a project that contains the third-party JAR and the native code DLL's. The fragment approach described by Alex Blewitt here didn't even find the DLL's at all.

http://www.eclipsezone.com/eclipse/forums/t64011.html

So I put everything in one plugin project to test. But I always get

java.lang.UnsatisfiedLinkError: ... Can't find dependent libraries

So I tried to do it as explained in here
http://wiki.eclipse.org/Eclipse_Plug-in_Development_FAQ#How_do_I_include_native_libraries_in_my_bundle.3F

I created an OSGi Service that calls System.loadLibrary() as described in the wiki, but on debugging I don't even come across the static init block that contains the loadLibrary() statements.

I read several times that it is an issue having dependent native code libraries, but fairly no solution except the loadLibrary() stuff. But maybe the place where I put those statements is wrong.

Can anybody give me a hint on how to solve this? Where to put the loadLibrary() statements?

Thanks,
Dirk
Re: Eclipse 4 and native code [message #1022753 is a reply to message #1021593] Fri, 22 March 2013 13:18 Go to previous messageGo to next message
Brian de Alwis is currently offline Brian de Alwis
Messages: 182
Registered: January 2012
Senior Member

DLLs are a pain, but even more so if you have DLLs relying on other DLLs. If you have inter-DLL dependencies, you have either (1) do loadLibrary() for each in turn, or (2) place the dependencies somewhere on your PATH/LD_LIBRARY_PATH/DYLD_LIBRARY_PATH.

Brian.


Eclipse Platform committer. Ask me about Eclipse support, training, and consulting.
Re: Eclipse 4 and native code [message #1022778 is a reply to message #1022753] Fri, 22 March 2013 13:56 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk Fauth
Messages: 1267
Registered: July 2012
Senior Member
Thanks Brian, I tried (1) but it seems to be too late. So I need to ensure that the code is executed at startup. I think one option would be to tell my product to start the plugin containing the service at a very early stage or need to determine how to tell it in another way. The idea behind it is to create an OSGi service that can be added to the Eclipse IDE, and there I do not know how to tell the product to start my plugin earlier. Any hints appreciated.
Re: Eclipse 4 and native code [message #1022790 is a reply to message #1022778] Fri, 22 March 2013 14:30 Go to previous messageGo to next message
Brian de Alwis is currently offline Brian de Alwis
Messages: 182
Registered: January 2012
Senior Member

It's hard to know what to suggest without seeing some sample code. If your class' static code isn't being called, then either that object hasn't been referenced or the exceptions in static code are being swallowed. You could put a class-load breakpoint there to be sure.

Put an exception breakpoint on UnsatisfiedLinkError too. At least you'll see what library you're dealing with.

Brian.


Eclipse Platform committer. Ask me about Eclipse support, training, and consulting.
Re: Eclipse 4 and native code [message #1022804 is a reply to message #1022790] Fri, 22 March 2013 14:54 Go to previous message
Dirk Fauth is currently offline Dirk Fauth
Messages: 1267
Registered: July 2012
Senior Member
Quote:
It's hard to know what to suggest without seeing some sample code.


Yes I know that. But I would need to put all of the plugins that I am trying to load in an archive. And I guess that would be too much. Smile

What I tried now was to create the OSGi service and everything related into one plugin instead of several ones, and there it works. So I need to search further there.

Thanks for your time. I definitely will get back here for further questions of if I find the issue and how to solve it. Smile
Previous Topic:E4 CSS engine - Platform and user-defined colors
Next Topic:CSS Styling of individual PartStacks
Goto Forum:
  


Current Time: Wed Sep 03 00:04:07 GMT 2014

Powered by FUDForum. Page generated in 0.03071 seconds