I tried to create a SWIG shell for this tiny little C ++ class for most of 3 hours without success, so I was hoping one of you could give me a small hand. I have the following class:
#include <stdio.h>
class Example {
public:
Example();
~Example();
int test();
};
#include "example.h"
Along with the implementation:
Example::Example()
{
printf("Example constructor called\n");
}
Example::~Example()
{
printf("Example destructor called\n");
}
int Example::test()
{
printf("Holy shit, I work!\n");
return 42;
}
I read the introduction page (www.swig.org/Doc1.3/Java.html) several times without gaining much understanding of the situation. My steps were
- Create example.i file
- Compile the original next to example_wrap.cxx (no links)
- link the resulting object files together
- Create a small java test file (see below)
- javac all .java files there and run
4 5 , ( " - , Java) ( , LD_LIBRARY_PATH , ).
public class test2 {
static {
String libpath = System.getProperty("java.library.path");
String currentDir = System.getProperty("user.dir");
System.setProperty("java.library.path", currentDir + ":" + libpath);
System.out.println(System.getProperty("java.library.path"));
System.loadLibrary("example");
}
public static void main(String[] args){
System.out.println("It loads!");
}
}
, - , , , example.i bash, .