Windows Installer

From Octave
Revision as of 14:59, 6 December 2015 by Philipn (talk | contribs) (→‎Tweaks)
Jump to navigation Jump to search
This article is about how to make the Windows installer; if you'd like just to use the installer, see Octave for Microsoft Windows.

GNU Octave is primarily developed on GNU/Linux and other POSIX conformal systems. There have been many efforts in the past to build ports of GNU Octave for Windows. Take a look at the various ports of Octave available for Windows here.

Recently some work has been done in maintaining a unified build system mxe-octave (a fork of MXE) which anyone can use to produce cross as well as native builds of GNU Octave for Windows and Mac OS X platforms. This page contains instructions about creating a Windows installer using mxe-octave.

Steps to create Windows Installer

  1. Install all requirements of MXE Octave.
  2. hg clone http://hg.octave.org/mxe-octave/
  3. cd mxe-octave
  4. autoconf
  5. ./configure
  6. make nsis-installer

Tweaks

  • Use make tar-dist or make zip-dist instead of nsis-installer if you want to build just an archive of the files to install on Windows instead of an installer wizard.
  • By default, packages will be built one at a time, but you may use make JOBS=4 (choose a number other than 4 that is appropriate for your system) to build each package in parallel. You may also combine this with the -j option for Make to build more than one package at a time, but be careful as using make -j4 JOBS=4 can result in as many as 16 jobs running at once.
  • Use ./configure --disable-strip-dist-files if you want to keep debug symbols in the installed binaries for debugging on Windows.
  • Include gdb in the installer by running make gdb before making the nsis-installer target.

Creating Octave development versions for Windows with mxe-octave

To roll your own octave for windows version with your favorite mods and patches, you can do as I have been doing (since over 2 years):

  1. Make the cross-build environment for Octave (=mxe-octave; see above)
  2. Build an Octave dist archive in Linux
  3. Move that into mxe-octave and cross-build Octave + windows installer.

For ensuing builds after a first build, you'll only need to follow steps 2 + a little amended step 3 (see below)

Step 1: Prepare mxe-octave

Clone the mxe-octave reop to some directory of your choice:

http://hg/octave.org/mxe-octave <name of mxe-octave build dir>

where <name of mxe-octave build dir> is some other name than just the default "mxe-octave". Once downloaded, go into the <name of mxe-octave build dir> subdir and do:

.autoconf
./configure <options you want>
make nsis-installer JOBS=<some number>

I usually have "--enable-devel-tools --enable-windows-64 --enable-octave=default --enable-binary-packages" as configure options and use JOBS=7 on my core i5 system.

  • the first configure option also includes gdb and an MSYS shell in the binary
  • the second avoids the ~700 MB max. array size limit for 32-bit executables but Octave will only run on 64-bit Windows (most Windows systems are 64 bit anyway these days). Note: this option does NOT imply 64-bit indexing
  • the third option is just for a placeholder; it'll invoke src/default-octave.mk (one of the three octave .mk files in mxe: src/stable-octave.mk and src/octave.mk, corresponding to the "--enable-octave=" configure option), I found that octave.mk lags a bit behind
  • the fourth option cross-compiles the binary modules in Octave-Forge packages, which wil save time when installing them once in Windows.

If you seriously want to work with gdb, also have --disable-strip-dist-files as configure option. However, in that case chances are that you cannot build an .exe installer anymore as it becomes too big for NSIS (that has a 2 GB installer file size limit) so instead of "make nsis-installer" you'll need to invoke

make zip-dist <options>

....and this results in all Octave dependencies being built in mxe-octave, plus some initial version of Octave itself.

Step 2: To build your first Octave-for Windows development version:

  • build Octave on Linux (in separate source and build trees) including your favorite mods and patches.
  • once Octave runs fine in Linux (using make check and trying your mods using ./run-octave & from the build dir, all of this still on the Linux side), do:
make all dist
  • move or copy the resulting dist archive to the <mxe-octave build>/pkg folder (or symlink to it from there)

Step 3: Building the Octave installer

  • be sure to adapt <mxe-octave build>/src/default-octave.mk to read "## No Checksum" at the $(PKG)_CHECKSUM line and check octave version and archive type (tar.gz rather than tar.bz2). The checksum is only needed when you download a dist archive from the Internet, not so much when you copy it within your own home network, let alone your own computer.
  • check if in the top of the main Makefile "default-octave" is mentioned for OCTAVE_TARGET rather than stable-octave" of just "octave" (that name refers to the .mk filename in the src folder).
  • ... and then run (in the <mxe-octave build> folder)
make nsis-installer <options>
-or-
make zip-dist <options>

Step 3A (second and later builds)

For next builds, mxe-octave is already configured and all dependencies have been built so the only thing to do is having a new Octave version + installer built:

  • move/copy the dist archive from step 2 into mxe-octave's pkg subdir
  • in <mxe-octave build> root dir do:
touch src/default-octave.mk

(to be sure mxe-octave picks up the new Octave archive). If you've renamed the dist archive, be sure it matches with the package name in src/default-octave.mk. Then do:

make nsis-installer
-or-
make zip-dist

Step 4: Install on Windows

  • move the installer in <mxe-octave build>/dist/ to the Windows side (USB thumb drive, LAN copy, whatever).
  • install it there.

If you've made a zip-dist you'll have to manually create the desktop and Start Menu shortcuts (for octave and the MSYS-shell).

Remarks

  • If you have several mxe-octavebuild dirs (for e.g., stable and several development versions) it is handy to have a separate pkg subdir symlinked to from all mxe-octave build dirs. That will save a lot of downloading bandwidth.
  • To keep mxe-octave up-to-date, from time to time do:
hg -v pull
hg -v update
  • However, do not keep mxe-octave build dirs for too long. I'd suggest to wipe a build dir after at most two or three months and start over with a fresh clone a la Step 1.
  • In the mean time, regularly clean up <mxe-octave build>/log to save disk space. After a first successful build there's no more use for the log subdirs for each package, so you can wipe them all.

Installing requirements of MXE Octave

MXE Octave requires a recent Unix system where all components as stated below are installed.

Debian (GNU/kFreeBSD & GNU/Linux)

aptitude install -R autoconf automake bash bison bzip2 \
                    cmake flex gettext git g++ intltool \
                    libffi-dev libtool libltdl-dev \
                    mercurial openssl libssl-dev \
                    libxml-parser-perl make patch perl \
                    pkg-config scons sed unzip wget \
                    xz-utils yasm autopoint zip

On 64-bit Debian, install also:

aptitude install -R g++-multilib libc6-dev-i386

If you are using Ubuntu, then you can do apt-get install foo instead of aptitude install -R foo.

On a fesh Linux Mint 16 x86_64, in addition to the above also install:

sudo apt-get install libc6-dev-i386 gcc-multilib libgmp3-dev libmpfr4 libmpfr-dev
sudo apt-get build-dep gcc-4.8

If not installed you will get error messages like "/usr/include/stdc-predef.h:30:26: fatal error: bits/predefs.h: No such file or directory" or "/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.8/libgcc.a when searching for -lgcc" when compiling ocaml-core. The packages libgmp3-dev libmpfr4 libmpfr-dev libmpc-dev are needed for compiling the build-gcc.

Fedora

yum install autoconf automake bash bison bzip2 cmake \
            flex gcc-c++ gettext git intltool make sed \
            libffi-devel libtool openssl-devel patch perl pkgconfig \
            scons yasm unzip wget xz

On 64-bit Fedora, there are open issues with the NSIS package.

FreeBSD

pkg_add -r automake111 autoconf268 bash bison cmake \
           flex gettext git gmake gsed intltool libffi libtool \
           openssl patch perl p5-XML-Parser pkg-config \
           scons unzip wget yasm

Ensure that /usr/local/bin precedes /usr/bin in your $PATH:
For C style shells, edit .cshrc

setenv PATH /usr/local/bin:$PATH

For Bourne shells, edit .profile

export PATH = /usr/local/bin:$PATH

On 64-bit FreeBSD, there are open issues with the NSIS package.

Frugalware

pacman-g2 -S autoconf automake bash bzip2 bison cmake \
             flex gcc gettext git intltool make sed libffi libtool \
             openssl patch perl perl-xml-parser pkgconfig \
             scons unzip wget xz xz-lzma yasm

On 64-bit Frugalware, there are open issues with the NSIS package.

Gentoo

emerge sys-devel/autoconf sys-devel/automake \
       app-shells/bash sys-devel/bison app-arch/bzip2 \
       dev-util/cmake sys-devel/flex sys-devel/gcc \
       sys-devel/gettext dev-vcs/git \
       dev-util/intltool sys-devel/make sys-apps/sed \
       dev-libs/libffi sys-devel/libtool dev-libs/openssl sys-devel/patch \
       dev-lang/perl dev-perl/XML-Parser \
       dev-util/pkgconfig dev-util/scons app-arch/unzip \
       net-misc/wget app-arch/xz-utils dev-lang/yasm

Mac OS X

Install Xcode 4 and MacPorts, then run:

sudo port install autoconf automake bison cmake flex \
                  gettext git-core gsed intltool libffi libtool \
                  openssl p5-xml-parser pkgconfig scons \
                  wget xz yasm

Mac OS X versions ≤ 10.6 are no longer supported.

MingW

Make sure to update and upgrade packages as some of the default versions of packages are too old to work correctly.

mingw-get update
mingw-get upgrade

And then get required packages.

mingw-get install autoconf bash msys-bison msys-flex gcc gcc-c++ \
                  gcc-fortran gettext msys-m4 msys-make msys-sed \
                  libiconv msys-openssl msys-patch msys-perl \
                  msys-libarchive msys-unzip msys-wget msys-bsdtar
   

You will also need to install Windows versions of Python and Ghostscript and ensure they are in visible in the PATH.

OpenSUSE

zypper install -R autoconf automake bash bison bzip2 \
                  cmake flex gcc-c++ gettext-tools git \
                  intltool libffi-devel libtool make openssl \
                  libopenssl-devel patch perl \
                  perl-XML-Parser pkg-config scons \
                  sed unzip wget xz yasm

On 64-bit openSUSE, install also:

zypper install -R gcc-32bit glibc-devel-32bit \
                  libgcc46-32bit libgomp46-32bit \
                  libstdc++46-devel-32bit

Creating an NSIS based installer

The make nsis-installer command produces a NSIS installer that is ready to be distributed.