Porting to other Platforms

The SDK contains two platform dependent components: the JNI library of libusbJava and the macro processor bmp. The package contains binaries (32 and 64 bit) for Linux and Windows.

In order to add support for other platform the two platform dependent components need to be rebuild.

Compiling the JNI library

The following description is for Unix-like operating systems.

  1. Change to the directory libusbJava-src in the SDK
  2. in Makefile: set JAVAPREFIX (around line 16) to the base directory of the JAVA JDK. ($JAVAPREFIX/include should contain jni.h)
  3. in Makefile: replace $(JAVAPREFIX)/include/linux in LIBINCS (around line 35) by the system specific directory
  4. in Makefile: Apply other system specific modifications if necessary
  5. Run make, this compiles the JNI library
  6. Run make install2, this copies the library to ../libusbJava

After a new JNI library has been compiled and installed the jar archives need to be repacked. This can be done by removing the jar file and by running make in the same directory.


The macro processor bmp is written in Freepascal. A Freepascal installation is required in order to compile the bmp.

  1. Change to the directory bmp in the SDK
  2. in Makefile: Apply system specific modifications if necessary
  3. Run make, this compiles the binary
  4. Run make install2, this copies the library to ../bin

NOTE that FreePascal recently (Jan 1st, 2012) released a major new version, 2.6.0. This includes extensive language changes, and breaks compatibility with the bmp code. The reason for why bmp will not compile with FPC 2.6.0 is noted here in the FPC 2.6.0 User Changes document.

A quick and dirty hack may be possible, but it's sensitive code (recursively parsing using a derived class). I'm not this conservative usually, but my (catfish) advice is simply to use an earlier version of FPC that supports passing derived classes to var- and out-parameters. It is confirmed that bmp will compile on FPC 1.0, 2.0 and 2.2 - these are no longer supported. I can further confirm that FPC 2.4.0 will successfully compile bmp (tested on 32-bit and 64-bit Mac OS X 10.6 Snow Leopard, on both genuine Apple hardware and Hackintosh rigs, and 64-bit Linux).

MacOS port

A MacOS port of the JNI library has been made available by a user. In order to run the jar packages generated with the SDK under MacOS the library file libusbJava.jnilib must be copied to the working directory. Warning: This file is a user contribution. Use it at your own risk. Note that this file only supports the Intel Platform (Universal Binary i386 and x86_64) - if you are running an old PowerPC system obviously an x86 binary will not work, you have to compile a version suitable for your system yourself.

A better solution is to install the libusb_compat port from MacPorts or homebrew and then compile the libusbJava SDK source using the catfish Makefile. This will produce both 32-bit and 64-bit (if your system supports it) JNI library files, which can either be installed into the system or simply copied into the folder used for ZTEX Java applications.

en/software/porting.txt · Last modified: 2012/07/04 21:25 by
Recent changes RSS feed Creative Commons License Powered by PHP Debian Driven by DokuWiki
[ZTEX Home] [Impressum]