Installation on Linux

From Rxtx

Jump to: navigation, search

The documentation below is a little dated and could do with some updating. Please could someone reformat and ensure their correctness:

Contents

Requirements

You will need JDK 1.4+ (JDK 1.3 might work), autoconf, automake, libtool, gnu make and gcc.

Note that you are recommended to use the JDK, as opposed to the gcc flavour, since the latter will most probably cause you issues. If your OS does not provide a proper version, or a package manager that will get it for you, then you can download the JDK from the Java SE Downloads page.

Installing from Source

Installing Java

If you don't already have Java installed on your system, you will need to install it. The best way, if possible, is to use the package manager for your distribution to install it. Failing that you can get a JDK (Java Developer Kit) installer from Sun's Java Developer web site. People who just want to run their Java applications can get the JRE installation, though note that you will not be able to develop or compile with the JRE. Since the general instructions are oriented towards developers, we recommend having the JDK installed.

If the environment variable JAVA_HOME is not defined, then it is recommend that you define it in your login script. For example if your Java installation is located at /usr/java/jdk6_03, then in a csh style shell run:

setenv JAVA_HOME /usr/java/jdk6_03

or an sh style shell run:

JAVA_HOME=/usr/java/jdk6_03
export JAVA_HOME

Installing RXTX

General Steps

Once you have downloaded the source, extract it (alternatively: get it from CVS), and then in a terminal window navigate to the extracted directory and type the command:

sh ./configure

This will configure the build and generate the necessary make files. configure will pick up the location of the Java installation from JAVA_HOME, look for the line that says something like:

/usr/local/java/jdk
configure: WARNING: using JAVA_HOME environmental variable

Note, that there may be supplementary options you may want to configure, though the standard options should suffice. To see what they are:

sh ./configure --help

Once configure has finished running, start the make process:

make
Note: Spaces in the path may cause the build to fail. If it does ensure the path does not have any spaces.

At this point there are several ways of 'installing' rxtx: using "make install", adding the libraries to your path, or using it with your IDE. These are explained in the following subsections.

Once you have completed the steps, RXTX should now be installed. See the development section for some example code to get you running.

Wed 22Jun2011
Notes on installing on Debian 6.0.1a
Author: Sergei Haramundanis bog10222@bogatir.com

(I'm editing the Linux Installation wiki page because there doesn't seem to be a more appropriate place)

As I wanted to use the Java/Linux rxtx libraries with an Arduino Uno prototype microcontroller, I looked at the libs available in Arduino 0022 which appeared to be the 2.1 version, so I went looking for the latest 2.2pre2.

Thankfully, Debian 6.0.1a includes a package so you don't have to build it.
Execute the following to install the package:

su - root
apt-get install librxtx-java

This installed the following (among other things):

-rw-r--r-- 1 root root 60866 Jun 25  2010 /usr/share/java/RXTXcomm-2.2pre2.jar
lrwxrwxrwx 1 root root    20 Jun 11 23:52 /usr/share/java/RXTXcomm.jar -> RXTXcomm-2.2pre2.jar
-rw-r--r-- 1 root root 48900 Jun 25  2010 /usr/lib/jni/librxtxSerial-2.2pre1.so
-rw-r--r-- 1 root root   857 Jun 25  2010 /usr/lib/jni/librxtxSerial.la
lrwxrwxrwx 1 root root    24 Jun 11 23:52 /usr/lib/jni/librxtxSerial.so -> librxtxSerial-2.2pre1.so

Since I also wanted to build it, I had to install the following supporting build utilities:

apt-get install autoconf (this installed GNU Autoconf 2.67)
apt-get install automake (this installed GNU automake 1.11.1)
apt-get install libtool (this installed GNU libtool 2.2.6b)
apt-get install make (this installed GNU Make 3.81)

After downloading and extracting to $HOME/Downloads/rxtx here's the build script I used:

date
cd rxtx-2.2pre2
echo "*** configure ***"
./configure --prefix=/home/sharamun/rxtx-2.2
echo "*** make install ***"
make install
date
echo "done."

On attempting a build, "make install" consistently fails with:

gcc -I/home/sharamun/Downloads/rxtx/rxtx-2.2pre2 -Ii686-pc-linux-gnu -I. -I/home/sharamun/Programs/jdk1.6.0_26/include -I/home/sharamun/Programs/jdk1.6.0_26/include
/./linux/ -g -O2 -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec -c /home/sharamun/Downloads/rxtx/rxtx-2.2pre2/./src/I2CImp.c  -fPIC -DPIC -o /home/sharamun/Downloads
/rxtx/rxtx-2.2pre2/i686-pc-linux-gnu/.libs/I2CImp.o
/home/sharamun/Downloads/rxtx/rxtx-2.2pre2/./src/I2CImp.c: In function 'Java_gnu_io_I2CPort_Initialize':
/home/sharamun/Downloads/rxtx/rxtx-2.2pre2/./src/I2CImp.c:135: error: 'UTS_RELEASE' undeclared (first use in this function)
/home/sharamun/Downloads/rxtx/rxtx-2.2pre2/./src/I2CImp.c:135: error: (Each undeclared identifier is reported only once
/home/sharamun/Downloads/rxtx/rxtx-2.2pre2/./src/I2CImp.c:135: error: for each function it appears in.)

However, it appeared to create the RXTXcomm.jar and librxtxSerial.so w/symbolic links, so I executed the following to get the compiled Java/Linux libs in a directory off of home:

mkdir $HOME/rxtx-2.2
cd $HOME/Downloads/rxtx
cp ./rxtx-2.2pre2/RXTXcomm.jar $HOME/rxtx-2.2
mv ./rxtx-2.2pre2/i686-pc-linux-gnu/.libs $HOME/rxtx-2.2/lib
mv ./rxtx-2.2pre2/i686-pc-linux-gnu/librxtxSerial.la $HOME/rxtx-2.2

...then included the following in $HOME/.bashrc:

export RXTX_HOME=/home/sharamun/rxtx-2.2
export LD_LIBRARY_PATH=${RXTX_HOME}/lib:${LD_LIBRARY_PATH}

Upon using it, I found that when executed on Linux the gnu.io.CommPortIdentifier serial devices did not include ttyACM so it would never recognize the Arduino Uno plugged in to the USB port on my system. I had to edit ./src/gnu/io/RXTXCommDriver.java to include the following after line 581:

"ttyACM",

Once I rebuilt it with this change, it successfully worked and I was good to go. I have since been using the locally built libraries without issue so far.

It would be nice if the rxtx developers would include this change in the source distribution package, as well as fixing "make install" which successfully builds the libs but fails to complete the deploy.

Until then, these notes should provide enough reference to work around these issues.

Questions/comments/additions/corrections are welcome, just drop me a line. Thanks.

Method 1: Make Install

You either do this as root user, or by using sudo:

sudo make install

The RXTX jar file and binary libraries will be put into the JDK's or JRE's lib/ext subdirectory.

Method 2: Adding to your path

  • Copy RXTXcomm.jar and librxtxSerial.so to a location of your choice.
  • Add the jar to your CLASSPATH, specifying the absolute path to the JAR, for example if it is in /home/myuser/javalibs, csh syntax and sh syntax:
 setenv CLASSPATH ${CLASSPATH}:/home/myuser/javalibs/RXTXcomm.jar
 export  CLASSPATH=$CLASSPATH:/home/myuser/javalibs/RXTXcomm.jar
  • Add the folder containing the native library to the LD_LIBRARY_PATH, for example if it is in /home/myuser/lib
 setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:/home/myuser/lib/
 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/myuser/lib/

Note, that since the atcual library has a version in its name, you should ensure that a symbolic link is made to the library using an unversioned name, in the same folder. For example:

 ln -s librxtxSerial-2.1-7.so librxtxSerial.so

Method 3: With an IDE

Also, if you are using an IDE such as Eclipse, you can opt to include them in your project instead. If your project is MyHelloWorld then locations would be:

  • MyHelloWorld/lib/RXTXcomm.jar
  • MyHelloWorld/librxtxSerial.so

Don't forget to include them in your build path.

Note, that since the atcual library has a version in its name, you should ensure that a symbolic link is made to the library using an unversioned name, in the same folder. For example:

 ln -s librxtxSerial-2.1-7.so librxtxSerial.so

Installing Binaries

Linux


Copy the binaries (librxtxSerial.so and librxtxParallel.so) to $JAVA_HOME/lib/i386

(to do for other systems)

Personal tools