Wrapping C++ code with SWIG to be used in Processing

Hi,

I'd like to use some C++ libraries in a Processing project but I am not sure how to do it (I am completely newbie in Processing and Java).

The way I proceeded is by using SWIG to create a shared library (.so) that can be then loaded (using the System.load command) in a Java application in the same way as explained in the tutorial:

http://www.swig.org/tutorial.html

This might be a super basic question, but my doubt is (I have not been able to find a solution in Google or Stackoverflow) how do I import this library into Processing?

Using the example provided in the link, neither:

System.load("/path/to/example.so") # I compiled the library with .so rather than .dll, I am using Mac OS X

nor

System.loadLibrary("example") # Putting the example.so file in the library folder

seem to actually import the library. When I try to do something like:

double var = example.fact(5); 

Processing complains saying that "Cannot find anything named example". Could you help me with this? Any hint on how to import .so libraries in Processing would be greatly appreciated.

Many thanks!

@Tryskele

Tagged:

Answers

  • I find the example in the page you link to (good idea) a bit too simplistic. Not even sure if it works.

    I found out http://www.chilkatsoft.com/java-loadLibrary-Linux.asp which shows that even if you loaded the library, you don't magically get an instance of the library in the namespace: you get a class, that you must instantiate the old way, with new.

Sign In or Register to comment.