Samstag, 21. August 2010

Howto install jhandles in octave 3.2 with ubuntu 10.04

Last evening I joined a discussion on the GNU Octave mailing list about a problem making jhandles work on the current ubuntu. I already succeeded with that on my own machine with octave 3.2.4 and opensuse 11.3 64 bit, so I thought it will work on ubuntu too and gave it a try in a virtual machine.

Ok so I did it with 32 bit ubuntu 10.04 in vmware player (had no chance to do it with 64 bit so please take care that some paths can be slightly different on 64 bit version):

Install the following packages in ubuntu

sudo apt-get install octave3.2 octave3.2-headers
sudo apt-get install openjdk-6-jre openjdk-6-jdk
sudo apt-get install libjogl-java
sudo apt-get install mesa-common-dev

The following symbolic links are a workaround to make the configure scripts of the installer find the packages and there may be better solutions, but at least it works.

cd /usr/lib
sudo cp -s /usr/lib/mesa/

cd /usr/bin

sudo cp -s /usr/share/java/jogl.jar .
sudo cp -s /usr/share/java/gluegen-rt.jar .

Download the octave java package 1.2.7 from octave forge
Download jhandles 0.3.5 from octave forge.

Extract the jhandles package and navigate to the src folder. Open the configure script with an editor of your choice.
In the lines 4335, 4337, 4341 and 4342 change

octave -qf


octave -q

Save the file.

(Delete only the character f make sure you do not change anything else, do not delete the character ` at the end of the lines).
Change into the folder where you downloaded this packages for example

cd ~/Downloads

Run octave as root to install the packages system wide

sudo octave

Then proceed in octave

setenv("JAVA_HOME", "/usr/lib/jvm/java-6-openjdk")

pkg install -verbose java-1.2.7.tar.gz

(you will get some compiler warnings which can safely be ignored)

check that the functions from the java package are really available and work.

help java_new
type java_new
x = java_new ("java.lang.StringBuffer", "Initial string")

None of these commands should give error messages. So at this point you have the java binding s successfully installed.

Let's proceed with jhandles:

pkg install -verbose jhandles-0.3.5

ignore the warnings and exit octave.

Add the following lines to your .octaverc file with an editor of your choice in your home directory (create this file if there is none) before you proceed.


Now start octave as normal user

The command pkg list should now show

java *| 1.2.7 | /usr/share/octave/packages/3.2/java-1.2.7
jhandles | 0.3.5 | /usr/share/octave/packages/3.2/jhandles-0.3.5

Test the jhandles functionality with the following code snippet:

pkg load jhandles
shading interp

Hopefully it works also for you.

Sonntag, 31. Januar 2010

Compiling atlas for GNU Octave on openSUSE 11.2

Having a full featured GNU Octave on openSUSE is not the most trivial thing at all. During the last years I always preferred to compile it myself. Unfortunately this means that I also need to compile a variety of libraries needed by Octave.

If you are a newbie to Octave you should not necessarily follow my description. There is some evidence that you don't need it. If your requirement is to have a GNU Octave with full capabilities, but do not need to care to much about the performance it will be better if you use the octave 3.2.0 package from the OBS (openSUSE build service) from version 11.1 by ars3niy (1 click install). It is fully compatible with openSUSE 11.2.

There is also a description how to build your own octave 3.2.3 rpm available at Sebastian Schöps blog.

Here comes my description what I did to have atlas (automatically tuned linear algebra software) available.

First of all I removed the atlas from OBS (it lead to segfaults for me on my machine) as well as the lapack package with zypper.

The whole process is based on a combination from the following pages
slightly adapted to my needs.

Download the latest stable atlas from SourceForge (this was 3.8.3). Before installing it I built my own lapack library following the advice for lapack in Building Atlas by Hand.
This gives me a static library lapack_LINUX.a which I renamed to liblapack.a and copied to /usr/local/lib64, I also need a dynamic library which I created by the following steps

In the directory where lapack was built
mkdir tmp
cp liblapack.a tmp/
cd tmp/
ar -x liblapack.a
gcc -fPIC -lgfortran -shared *.o -Wl,-soname, -o

sudo cp /usr/local/lib64/
cd /usr/local/lib64
sudo cp -s

and then followed the rest of the "Building Atlas by Hand" article.

The default install of the atlas library puts them into /usr/local/lib/atlas/ which is not appropriate for me since I have a 64 bit machine. I decided to solve this with symbolic links because then I have not to think about it if I recompile it sometime later.

cd /usr/local/lib64
sudo cp -s ../lib/atlas/* .

Running configure for GNU Octave 3.2.3 properly detects the atlas and the corresponding lapack library (but it chooses the sequential versions).

To make Octave use the threaded versions so that I have benefit from the multicore machine I needed to tweak the file Makeconf (created by ./configure).

search for the line
BLAS_LIBS = -llapack -lcblas -lf77blas -latlas
and substitute -lcblas by -lptcblas and -lf77blas by -lptf77blas

make -j 4
and waiting some time
make check
sudo make install
my Octave runs now properly with the multithreaded libraries.