|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
Loading a shared lib from generated java classHi,
This seems like such a simple thing, but I can't figure out how to specify it in the interface file. I want to pass through some Java code verbatim from the interface file into a given generated java class. The reason being, I want the swig-generated java class to load the .so shared library instead of having to do it in the end user application. In other words, what I want it to spit out is this: package libmyApi; public class utils { ... static { System.loadLibrary("myApi"); } protected utils(long cPtr, boolean cMemoryOwn) ... When I manually insert the loadLibrary into the swig-generated file like this, it seems to work... the question is, how can I get swig to spit it out this way? I can't figure out how to add the "static" initialization section. I have tried many, many combinations of %init, %inline, %extend, etc... but no luck. Any ideas? TIA. ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ Swig-user mailing list Swig-user@... https://lists.sourceforge.net/lists/listinfo/swig-user |
|
|
Re: Loading a shared lib from generated java class2009/10/23 false <lawson08@...>:
> Hi, > > This seems like such a simple thing, but I can't figure out how to specify it in the interface file. > > I want to pass through some Java code verbatim from the interface file into a given generated java class. The reason being, I want the swig-generated java class to load the .so shared library instead of having to do it in the end user application. > > In other words, what I want it to spit out is this: > > package libmyApi; > public class utils { > ... > > static { > System.loadLibrary("myApi"); > } > > protected utils(long cPtr, boolean cMemoryOwn) ... > > > When I manually insert the loadLibrary into the swig-generated file like this, it seems to work... the question is, how can I get swig to spit it out this way? > > I can't figure out how to add the "static" initialization section. I have tried many, many combinations of %init, %inline, %extend, etc... but no luck. Any ideas? TIA. %pragma(java) jniclasscode=%{ static { try { System.loadLibrary("metrics"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load. \n" + e); System.exit(1); } } %} worked for me last time I used swig for java things... Alan ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ Swig-user mailing list Swig-user@... https://lists.sourceforge.net/lists/listinfo/swig-user |
| Free embeddable forum powered by Nabble | Forum Help |