Brief explanation for the octave build tool kit under the MinGW

(First update at May 4 28, 2009: Last modified April 28, 2009.)

Preface

This document gives least information for the usage. Please collect detailed information with a search engine like the Google. The purpose of this tool kit is to be help to build octave using the optimized BLAS to your CPU, for example the ATLAS or GotoBLAS.

If you need not to used an optimized BLAS, you can use the blas source files in the octave source tar ball. However the speed of linear algebra calculation is slow and building octave from source is not effective to you. For most people, I strongly recommned to use prebuild binaries provided by the Benjamin.

http://sourceforge.net/project/showfiles.php?group_id=2888&package_id=287261

Benjamin is now preparing the binaries of octave 3.0.5 using the mingw GCC compliers.

If you would like to build octave which uses libstdc++ dynamic link libraries, by which size of .oct files will be reduced for large amount. Please visit,

http://sourceforge.net/scm/?type=svn&group_id=2888 You can download the build tools from them,

 svn co https://octave.svn.sourceforge.net/svnroot/octave/trunk/octave-forge/admin/Windows/mingw32 mingw32

You may find the Subversion tool for win32 tools usinf Google and so on.

No Warranty

Please use these at your own risk.

From my experience, the build under the MinGW is very delicate. I cannot assure that the build of octave will be not always successful by this tool kit.

1. Required tools and libraries etc.

I do not recommend to install the tools below in the folder name of which has white space(s), e.g. C:\Progrgam Files. In my case, I make a folder 'C:\Programs' and install tools in the sub folder like C:\Programs\cygwin, C:\Programs\MinGW and so on.

BLAS

ATLAS and GotoBLAS are famous and can be used free of charge under the thier license limitation.

Please see the details in their home page. Both require the cygwin on the building libraries. Please install make, gcc-4, and gfortran-4 In addition to the default cygwin install. For the Atlas build, the name of c-complier and fortran compiler assumed to be gcc and gfortran, respectively. If you have installed both gcc-3 and gcc-4. Rename gcc.exe to gcc-3.exe, temporarilly. After that copy gcc-4.exe and gfortran-4.exe to gcc.exe and gfortran.exe, respectively. Atfer libraries will be build, do not forget to rename back the file names to those of before changes.

Important Note for GotoBLAS

The license of the GotoBLAS is under the UT TACC Research License. The term of 'UT TACC' means the Texas Advanced Computing Center of The University of Texas at Austin. The software and documentation can be used without charge to anyone for academic, research, experimental or personal use. To distribute or make other use of the software, it is required to purchase a license to do so from the University of Texas.

Please see in the detail for the UT TACC Research License at

http://svn.pardus.org.tr/uludag/trunk/pisi/licenses/tacc

You cannot distribute the octave binaries built with GotoBLAS to any other persons due to incompatibility the GPL V3 license, which is applied to Octave and the UT TACC license, which is applied to the GotoBLAS.

Msys

Please see MinGW/Msys home page and visit "InstallingMSYS" tutorial. In that tutorial, the MSYS 1.0.10 is the first to be installed. After that you can extract tar.gz and tar.bz2 files, respectively, as,

  tar xvfkz xxxx.tar.gz
  tar xvfkj xxxx.tar.bz2

After install process in the tutorial finished, I recommned addtionally to install Msys version of the recent autoconf, automake, libtool, make, crypto, and texinfo.

After the Mingw compliers, tools and libraries are installed, set the file of 'fstab' in ....\msys\1.0\etc is described. For example,

c:/Programs/mingw /mingw
c:/Programs/GnuWin32 /GnuWin32

MinGW + GCC 4.3.3-dw2 TDM

Please download GCC 4.3.3-1-dw2 TDM (gcc-dw2, g++-dw2, gfotran-dw2) from in zip compressed files. Please read *** Manual Installation *** in README-gcc-tdm.txt. Uncompress all MinGW and GCC 4.3.3-dw2 TDM components to in one folder. I am installing them into C:\programs\MinGW.

GnuWin32

The packacges of bison, flex, gperf, groff, and texinfo are used as the comand tool for 'make' The packages Pcre, PDCurses, readline, regex used as the external libraries.

For each tool pleases download "Complete package, except sources". Each package has installer so that install is easy. Please install all packages in the same folder in ....\GnuWin32. I installed the packages in C:\Programs\GnuWin32.

The disributed libraries and the gnuplot 4.3 (cvs) and etcs.

The package OctaveBuild.zip includes the tools, dll files, libraries, include files which are required for building octave and some of these are also reuired for execution of the octave.

This tool kit is zip compressed. The file name is 'OctaveBuild.zip'. You can get the folder named 'OctaveBuild' after zipped file is extracted. You can place it wherever you like. I place it to the C:\Programs\OctaveBuild


2. Building octave.

Copy optmized BLAS libraries and include files

In the .../OctaveBuild folder, you will find, you will find the sub-folders:

 bin/
 copyright/
 include/
 lib/
 libexec/
 share/

In the case of the ATLAS, you can find lib and include folders at /usr/local/atlas in the cygwin path. If your cygwin is installed to C:\Programs\cygwin, you will find the both ib and include folders in C:\Programs\cygwin\usr\local\atlas. Please copy the both folders and paste them to .../OctaveBuild (In my case, to C:\Programs\OctaveBuild)

In the case of the GotoBLAS, you will find a library file in the root of GotoBLAS source folder like, libgoto_(cpu name).a, for example libgoto_prescottp-r1.26.a. Please copy it to the .../OctaveBuild/lib (In my case, to C:\Programs\OctaveBuild\lib) and rename it as libgoto.a.

Octave build

Download the octave source file from http://www.gnu.org/software/octave/download.html. (bz2 file is more compact than gz file.) If you will build octave at D:\tmp, please copy 'octave-3.0.5.tar.bz2' to D:\tmp. And then please execute msys, and copy the below command lines and paste to Msys prompt,

cd "D:\tmp"
tar xvfkj octave-3.0.5.tar.bz2
then the folder 'octave-3.0.5' is created. In the case that 'OctaveBuild' is placed at C:\Programs\OctaveBuild and the ATLAS is used as the optimized BLAS, copy the below command lines and paste to Msys prompt,
cd ./octave-3.0.5
export PATH=$PATH:/c/Programs/OctaveBuild/bin
export CC=gcc-dw2
export CXX=g++-dw2
export F77=gfortran-dw2
export FFLAGS='-O3 -fomit-frame-pointer'
export CFLAGS='-O3 -fomit-frame-pointer'
export CXXFLAGS='-O3 -fomit-frame-pointer'
export LDFLAGS='-L/c/Programs/OctaveBuild/lib -L/GnuWin32/lib'
export CPPFLAGS='-I/c/Programs/OctaveBuild/include -I/GnuWin32/include'
./configure --prefix=/c/Programs/OctaveBuild --with-blas='-lf77blas -lcblas -latlas' --without-lapack

If you use the GotoBLAS, './configure ...' command will be in the following,

./configure --prefix=/c/Programs/OctaveBuild --with-blas='-lgoto' --without-lapack

Please check './confugre ... ' will be successful and then copy the below command lines and paste to Msys prompt

make
make check
make install-strip
Please pray the make process being successful.

Note

In genaral case, the optimizing option of '-O3 -fomit-frame-pointer' is not recommended. However, I have no trouble with this option.

At present, I cannot get successful results for the multi-threaded ATLAS and the GotoBLAS with SMP >=2.

I once get successful results with multi-threaded ALTAS with pthread-win32 using GCC-4.3.3-sjlj. However that only one time, I have not gotten successful results yet now. If you would like to use the multi-threaded ATLAS and the GotoBLAS with 'SMP = 1' in the Makefile.rule, please build octave under the cygwin.

Start up batch file

After 'make install-strip' is finished, please prepare a start up batch file in .../bin folder (In my case, in 'C:\Programs\OctaveBuild\bin') named 'octave.bat' in the following

Rem Octave starup batch file 'octave.bat'
@echo off

Rem Please custumize the below to adjust your instaling Path settings
set OctavePath=C:\Programs\OctaveBuild
set MsysPath=C:\Programs\Msys\1.0.11
set MinGWPath=C:\Programs\MinGW
set GnuWin32Path=C:\Programs\GnuWin32

Rem Path setting
Path %Path%;%OctavePath%\bin;%MsysPath%\bin;%MinGWPath%\bin;%GnuWin32Path%\bin

Rem Set local and Time Zone setting
Rem Please custamize according to your environments
Rem set LANG=ja_JP.SJIS rem Japanese Sjis
Rem set TZ=JST-9 rem Japanese Time Zone
set LANG=en
set TZ=GMT


Rem execute octave
octave

Rem terminate the batch script
exit

I think that it is better to make a shortcut to the batch file and customize it. By clicking the shotcut with a right mouse button and change properties. Please custumize icon, buffer size, number of the buffur, edit option ('quiich edit mode' is highly recommended), font, screes buffer size, window size of screen, foreground or background color of screen, and so on.

For 'quick edit mode', please see the detai in the page indicated the below url

http://blogs.msdn.com/adioltean/archive/2004/12/27/332974.aspx

3. Miscellaneous

Modification of mkoctfile script

Please comment out the lines indicated the below in the files of 'mkoctfile' and 'mkoctfile-3.0.x', respectively.

#if [ -n "$OCTAVE_HOME" ]; then
#  DEFAULT_BINDIR="`echo $DEFAULT_BINDIR | $SED "s,^$OCTAVE_PREFIX,$OCTAVE_HOME,"`"
#  DEFAULT_INCLUDEDIR="`echo $DEFAULT_INCLUDEDIR | $SED "s,^$OCTAVE_PREFIX,$OCTAVE_HOME,"`"
#  DEFAULT_LIBDIR="`echo $DEFAULT_LIBDIR | $SED "s,^$OCTAVE_PREFIX,$OCTAVE_HOME,"`"
#  DEFAULT_OCTINCLUDEDIR="`echo $DEFAULT_OCTINCLUDEDIR | $SED "s,^$OCTAVE_PREFIX,$OCTAVE_HOME,"`"
#  DEFAULT_OCTLIBDIR="`echo $DEFAULT_OCTLIBDIR | $SED "s,^$OCTAVE_PREFIX,$OCTAVE_HOME,"`"
#fi

Note

The mkoctfile.m octave script does not work. Please use it from Msys prompt like,

octave> system('sh');

$ mkoctfile -s foo.cc
$ exit

octave>