Building Octave on Windows
I recently created a simple script for Matrix Multiplication Tests in Octave (or Matlab). I was curious about how to build it. Get Involved (octave.org) links to the Mercurial SCM (mercurial-scm.org) website. It has been more than a decade since I last used Mercurial. The TortoiseHg 6.2.3 MSI installer brings KDiff3, which I haven’t seen in ages either.
cd \dev\repos
hg clone https://hg.octave.org/octave
Developer FAQ – Octave has a discourse forum (just like LLVM) and I’m realizing I need to jump into these forums and at least hear what’s happening. Instructions for building on Windows have a separate page 😀 Building on Microsoft Windows – Octave. MSYS2 is used for building natively, and since I used it to build Elmer, I might as well see how well it works for Octave.
pacman -S base-devel mingw-w64-x86_64-autotools mingw-w64-x86_64-cc mingw-w64-x86_64-gcc-fortran mingw-w64-x86_64-lapack mingw-w64-x86_64-openblas mingw-w64-x86_64-pcre mingw-w64-x86_64-arpack mingw-w64-x86_64-curl mingw-w64-x86_64-fftw mingw-w64-x86_64-fltk mingw-w64-x86_64-gl2ps mingw-w64-x86_64-glpk mingw-w64-x86_64-ghostscript mingw-w64-x86_64-gnuplot mingw-w64-x86_64-graphicsmagick mingw-w64-x86_64-hdf5 mingw-w64-x86_64-libsndfile mingw-w64-x86_64-portaudio mingw-w64-x86_64-qhull mingw-w64-x86_64-qrupdate mingw-w64-x86_64-qscintilla mingw-w64-x86_64-qt5 mingw-w64-x86_64-rapidjson mingw-w64-x86_64-suitesparse mingw-w64-x86_64-sundials git mercurial mingw-w64-x86_64-ccache mingw-w64-x86_64-icoutils mingw-w64-x86_64-librsvg texinfo unzip zip
The vastness of qt5 is the first thing that confronts me when I run this command. The install size of all the packages is about 3.5 GB. Installation takes about 7.5 minutes.
cd /c/dev/repos/octave
./bootstrap
mkdir -p .build
cd .build
../configure --disable-docs ac_cv_search_tputs=-ltermcap
Digging into Configure Failures
Configure fails on my machine with this error the first time I run it:
configure: loading site script /etc/config.site
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a race-free mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether UID '197630' is supported by ustar format... yes
checking whether GID '197630' is supported by ustar format... yes
checking how to create a ustar tar archive... gnutar
checking whether make supports nested variables... (cached) yes
checking build system type... x86_64-w64-mingw32
checking host system type... x86_64-w64-mingw32
checking whether make supports the include directive... yes (GNU style)
checking for gcc... no
checking for cc... no
checking for cl.exe... no
checking for clang... no
configure: error: in `/c/dev/repos/octave/.build':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
I try updating the .bash_profile
as suggested but this doesn’t help:
echo "export PERL5SHELL=\"bash -l -c\"" >> ~/.bash_profile
The Stack Overflow post linux – configure: error: no acceptable C compiler found in $PATH makes me realize that gcc is not installed. It also reminds me of how I installed dependencies when Investigating how to Build Elmer on Windows. I added instructions to the readme at ElmerCSC/elmerfem: Official git repository of Elmer FEM software (github.com) (see this PR). This command from that readme should installs the compiler tools I think will be necessary:
pacman -S --noconfirm --needed base-devel mingw-w64-x86_64-toolchain mingw64/mingw-w64-x86_64-cmake mingw64/mingw-w64-x86_64-openblas mingw64/mingw-w64-x86_64-qt5 mingw64/mingw-w64-x86_64-qwt-qt5 mingw64/mingw-w64-x86_64-nsis git
Unfortunately, gcc is still not found. I verified that gcc is indeed on disk C:\dev\software\msys64\mingw64\bin\gcc.exe
using the path structure at Package: mingw-w64-x86_64-gcc – MSYS2 Packages. The top answer did suggest modifying the PATH but I’m perplexed at how the compiler was found in the ElmerFEM build environment since it also cannot find the gcc command.
export PATH=${PATH}:c/dev/software/msys64/mingw64/bin
So, the culprit turns out to be the fact that I was using the UCRT shell instead of the MINGW64 shell. I think this bit me with Elmer as well. Should have carefully reviewed that post (see the Custom Generator in MSYS section).
Building the Code
Using the correct MSYS terminal allows configure to work. It takes 4m:45s on my machine. Here is the summary after all the flags are displayed. This piques my curiosity about where Java methods are called by Octave but I’ll ignore it for now!
Default pager: less
gnuplot: gnuplot
Build Octave Qt GUI: yes (version: 5)
Build Java interface: no
Build static libraries: no
Build shared libraries: yes
Dynamic Linking API: LoadLibrary
Include support for GNU readline: yes
Use push parser in command line REPL: yes
64-bit array dims and indexing: yes
64-bit BLAS array dims and indexing: no
OpenMP SMP multithreading: yes
Truncate intermediate FP results: yes
Build cross tools: no
Build docs: no
configure: WARNING: JAVA_HOME environment variable not initialized. Auto-detection will proceed but is unreliable.
configure: WARNING: No Java executable found. Octave will not be able to call Java methods.
configure: WARNING: building documentation disabled; make dist will fail.
configure:
configure: NOTE: Libraries or auxiliary programs may be skipped if they are not found
configure: NOTE: OR if they are missing required features on your system.
Build Octave by running make with these options. The last few lines of output from a successful build are shown below as well. The build took 21min on my new desktop.
make all -j8
...
GEN libinterp/dldfcn/gzip.oct
GEN doc/interpreter/doc-cache
Octave successfully built. Now choose from the following:
./run-octave - to run in place to test before installing
make check - to run the tests
make install - to install (PREFIX=/mingw64)
HG ID for this build is "5744dac88986"
make[2]: Leaving directory '/c/dev/repos/octave/.build'
make[1]: Leaving directory '/c/dev/repos/octave/.build'
./run-octave
launches the Octave command line. Since we built with Qt, we can launch the Octave GUI using this command:
./src/octave-gui --gui
Unfortunately, there is a segmentation fault when I close Octave! TODO: Why?