The attached patch creates Java language bindings for
the libgphoto2 library. It uses SWIG to automatically
generate the necessary C and Java code. I have focused
on Java, but SWIG supports other high-level languages
such as C#, Perl, PHP, Python, Tcl and others. For
more information on SWIG, see http://www.swig.org/
This should be suitable to include in the 2.1.6
release, or you may want to wait until 2.2.0.
I have placed the swig files in a subdirectory called
"swig-java". I have written a build script called
"make-swig-java.sh", but eventually this could be
integrated into the libtool build process used by the
rest of the library. I have built and tested on Linux
with Fedora Core 3 and RedHat Enterprise 3. There is
certainly some non-portable stuff in the build script,
but generated code should be as portable as SWIG.
This file and these scripts focus on Java. Other
languages should be simple since the SWIG interface
file should be the same. Note that the SWIG wrapper
libraries can only support one language at a time (at
least not without a lot more work), so if you compile
for another language you may want to create a separate
directory for those files.
To build the Java bindings, first configure and build
the libgphoto2 library.
Then cd to the swig-java directory and run
"make-swig-java.sh"
copy the jni library to your jre/lib/i386 directory,
such as:
cp -a libgphoto2_jni.so
/opt/SUNWappserver/jdk/jre/lib/i386/
then you should be able to run the javatest.java file:
java -classpath
swig-java:swig-java/swig-org-gphoto2.jar javatest
The two files, "libgphoto2_jni.so" and
"swig-org-gphoto2.jar" (plus the standard libgphoto2
install) should be all that you need to include in your
java project.
TODO:
Update the GPhoto2 Manual section 7.1 to mention these
SWIG files
This swig-java build process needs to be integrated
into the libtool process used by the rest of the library
Bindings for other languages supported by SWIG
May need more helper functions in the SWIG interface
file for dereferencing pointers and converting types.
You can reach me at "jason.watson@agrios.net". Hope
someone gets some use out of this! :)
Jason
libgphoto2-swig-java.patch
Logged In: YES
user_id=27487
I'll take care of this.
Logged In: YES
user_id=27487
committed as is for the 2.2 release.
thanks for the patch.