Closed GoogleCodeExporter closed 9 years ago
[deleted comment]
Hello Aleksandar,
Thank you for your report (and for the workaround !).
(EDIT: deleted a silly comment of mine, didn't realize that library.custom is
JNAerator's own library location override mechanism... this tells you how often
I use this hack ;-))
Would you have any pointer to an OSGI bundle-howto, so that I can reproduce the
issue and play a bit ?
Cheers
--
Olivier
Original comment by olivier.chafik@gmail.com
on 30 Nov 2010 at 4:08
Salut Olivier,
As seen in my case, I use Apache Felix. To use it as an OSGi container you can
get starting information from this page:
http://felix.apache.org/site/apache-felix-framework-usage-documentation.html
Here is a 5-step quick guide:
1. Download Felix Framework Distribution 3.0.6:
http://felix.apache.org/site/downloads.html
2. If you're using Maven, create a test project and do the following to your
POM:
Add a dependency to OSGi:
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.osgi.core</artifactId>
<version>1.4.0</version>
</dependency>
Set packaging to bundle:
<packaging>bundle</packaging>
Create and configure a bundle activator:
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-Activator>xx.CustomBundleActivator</Bundle-Activator>
</instructions>
</configuration>
</plugin>
3. Inside the start() method of your CustomBundleActivator (implementation of
org.osgi.framework.BundleActivator), use the Custom.INSTANCE field to include
the JNAerator magic in the mix.
4. Put your bundle in Felix' bundle/ directory
5. Run Felix:
java -jar bin/felix.jar
Hope that helps,
Alex
Original comment by A.Kambu...@gmail.com
on 1 Dec 2010 at 7:10
btw Here is the code by JNAerator:
public static final java.lang.String JNA_LIBRARY_NAME = LibraryExtractor.getLibraryPath("Custom", true, xx.CustomLibrary.class);
public static final NativeLibrary JNA_NATIVE_LIB = NativeLibrary.getInstance(xx.CustomLibrary.JNA_LIBRARY_NAME, com.ochafik.lang.jnaerator.runtime.MangledFunctionMapper.DEFAULT_OPTIONS);
public static final CustomLibrary INSTANCE = (CustomLibrary)Native.loadLibrary(xx.CustomLibrary.JNA_LIBRARY_NAME, xx.CustomLibrary.class, com.ochafik.lang.jnaerator.runtime.MangledFunctionMapper.DEFAULT_OPTIONS);
I didn't understand why it's different from your example:
http://code.google.com/p/jnaerator/wiki/SimpleMeaningfulExample
public TestLibrary INSTANCE =
(TestLibrary)com.sun.jna.Native.loadLibrary("test", TestLibrary.class);
I tried different command line options but I couldn't remove the call to
LibraryExtractor.getLibraryPath(). Maybe only -skipLibraryInstance, but I don't
like it as a solution because then I'll have to write stuff in my code.
Original comment by A.Kambu...@gmail.com
on 1 Dec 2010 at 7:34
Hi,
The workaround mentioned in the initial report does not work for me. I don't
even use jna.library.path at all: because my native libraries have other
dependencies, I set the LD_LIBRARY_PATH environment variable instead. It
doesn't seem to make any difference if I set jna.library.path or library.custom
at all.
I now use -skipLibraryInstance while generating the code, and lose the
getLibraryPath call in my own code. Maybe not so clean, but it works for me.
By the way, I use JNAerator for some Eclipse plug-ins which need to access
native libraries. Eclipse is also OSGi based, which is why this issue shows up
for me.
Original comment by tim.slec...@gmail.com
on 7 Jun 2011 at 9:10
Hi,
This issue moved to Github :
https://github.com/ochafik/nativelibs4java/issues/153
Thanks for not updating this page anymore and adding further comments on Github.
Cheers
--
zOlive
Original comment by olivier.chafik@gmail.com
on 1 Sep 2011 at 7:26
Original issue reported on code.google.com by
A.Kambu...@gmail.com
on 30 Nov 2010 at 3:21