For matrix computation Octave libraries
can be linked with your own C++ programs to produce executable code which
runs without the use of the octave command line.
A problem with the standard installation of octave-2.0.17 is that
the libraries are compiled as static. This means that any code that links
these libraries has very large executable files (>3MByte). The solution
is to compile octave with shared libraries. The procedure I used to create
shared libraries is given below. Paths are going to vary according to your
installation. I could create a script file to do this but it would be limited
to this release of octave, I thought that by giving the details they could
be modified to work with newer releases of octave.
[andrew@PC1 andrew]$ cd SourceCode/
[andrew@PC1 SourceCode]$ tar -zxvf ~/Downloads/octave-2.0.17.tar.gz
[andrew@PC1 SourceCode]$ cd octave-2.0.17/kpathsea/
[andrew@PC1 kpathsea]$ kwrite acklibtool.m4
The snippet of code below gives the changes required to acklibtool.m4.
The changes allow a shared library to be compiled.
## For use with Octave, ignore these options and only build
static libraries.
##
## Argument parsing: we support --enable-shared and --enable-static.
#AC_ARG_ENABLE(shared,
#[ --enable-shared
build shared libraries [default=no]],,
# enable_shared=no)
##
#AC_ARG_ENABLE(static,
#[ --enable-static
build static libraries [default=yes]],,
# enable_static=yes)
enable_shared=no
enable_shared=yes
enable_static=yes
#
The red line is to be removed and
the green line is to be inserted. Just
change the 'no' to a 'yes'.
[andrew@PC1 kpathsea]$ autoconf
[andrew@PC1 kpathsea]$ cd ..
[andrew@PC1 octave-2.0.17]$ ./configure --enable-shared
[andrew@PC1 octave-2.0.17]$ make
[andrew@PC1 octave-2.0.17]$ su root
[root@PC1 octave-2.0.17]# make install
[root@PC1 octave-2.0.17]# cp kpathsea/SHARED/libkpathsea.so* /usr/local/lib/octave/
[root@PC1 octave-2.0.17]# rm -f /usr/local/lib/octave/lib*.a
[root@PC1 octave-2.0.17]# exit
Now you should only be left with shared libraries in /usr/local/lib/octave.
I have put together a
small C++ program that multiplies two matrices using octave. Also I have the
LMS & RLS Demo written using Octave libraries.