问题
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....
回答1:
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.
回答2:
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.
回答3:
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.
来源:https://stackoverflow.com/questions/1347684/what-is-the-preferred-way-to-load-a-dll-on-an-eclipse-rcp-plugin