views:

349

answers:

3

I have an Eclipse RCP plugin that requires a DLL.

What is the recommended best practice to add the DLL reference to the MANIFEST? Where should the DLL be located, what is the recommended directory name?

I have read conflicting practices. Some ask you to create a folder with the architecture and processor type, some ask to set some platform filters on the Manifest....

A: 

I'd follow the example of the org.eclipse.swt.win32 fragment and bundle them in the root of the jar.

For reference, there is a section of the SWT Examples documentation that describes how to run the examples standalone.

Rich Seller
I'd be careful about following the practices you find in the actual Eclipse code as they often have a mix of styles and are, generally, not using the latest recommendations (always the problem with a mature code-base).
hbunny
@stevendick I'm not clear what your point is, my answer suggests to use a fragment and put the dll in the jar, essentially the same as Malaxeur's later answer which you recommend
Rich Seller
Yes, the basic principle is the same, but most of the Eclipse code I've seen doesn't use the standard OSGi filters to control which fragments are loaded at runtime. I see that Malaxeur's suggestion uses Eclipse manifest extension rather than standard OSGi.
hbunny
+2  A: 

The best way in an eclipse application is to use plug-in fragments. A standard eclipse project (with dlls) will have multiple fragments for all supported platforms. The fragments will only be activated if the target platforms (specified in the Platform Filter).

From the eclipse documentation (provided with a standard eclipse install)

A Platform filter is a valid LDAP string that must evaluate to true in a running system for the the plug-in to run. For example, the following filter indicates that the plug-in is designed to only run on platforms with a win32 windowing system: Eclipse-PlatformFilter: (ws=win32). If a user attempts to run Eclipse on a platform that does not meet this requirement, the plug-in will be silently ignored by the runtime.

Malaxeur
I suggest using the standard OSGi filters rather than Eclipse's custom Eclipse-PlatformFilter header, if possible.
hbunny
This is what I am using, but using OSGI filters as suggested by steven
Mario Ortegón
+1  A: 

Since Eclipse RCP is based on OSGi, you can use also check the OSGi 4.1 documentation on handling native code. I believe the Eclipse guys have started to recommend the OSGi approach, but I can't remember where I saw the recommendation.

I've used Malaxeur's suggestion with using fragments and filters. The actual layout inside the fragment/bundle doesn't matter, though I'd create a separate lib directory if I had more than one library.

The OSGi 4.1 specification is here.

hbunny