Building on Microsoft Windows

From Octave
Revision as of 03:17, 14 June 2020 by Siko1056 (talk | contribs) (→‎Virtual Machine: Some wiki markup.)
Jump to navigation Jump to search

This page is directed towards new developers that are interested in contributing to Octave. There should be little requirements to follow these steps.

Contributing to Octave

Octave development is done mainly on Linux. But if you are running Windows, you can contribute to Octave nevertheless.

The easiest way to contribute (not only from Windows) is probably by changing or adding .m files.

If you found something you'd like to fix or improve, check out the bug tracker. It might have already been fixed in the development or (unreleased) stable version.

Octave is version controlled in a Mercurial repository. There are several Mercurial clients for Windows. One that nicely integrates with the Windows Explorer and that offers an easy to learn user interface is TortoiseHg. It is also quite easy to create Mercurial patches with that software. Those are the preferred way of contributing to Octave.

Building Octave

If you want to contribute changes to C++ files or are interested in testing the latest development or (unreleased) stable release, you can build Octave from source.

There is currently no maintained way to build Octave on Windows directly. But it is still possible to build Octave on Windows machines using virtual machines or Microsoft's Windows Subsystem for Linux.

Virtual Machine

Most of Octave's developers are running Debian or Ubuntu [1]. So these are probably the Linux distributions for which you are most likely to get help if you should run into issues. The following focuses mainly on Ubuntu.

VMWare Player is free (as in no costs) for non-commercial use.

There are several sources for free complete Linux VM images on the web. One of them is osboxes.org. You can download an Ubuntu image for VMWare Player from their side. After the download has finished, unzip the image.

You also need a .vmx file to be able to start the Virtual Machine with VMWare Player. To create a .vmx file with minimal settings, open a text editor and save the following to a file called Ubuntu.vmx next to the VM image you downloaded:

File: Ubuntu.vmx
.encoding = "windows-1252"
config.version = "8"
virtualHW.version = "8"
scsi0.present = "TRUE"
scsi0.virtualDev = "lsilogic"
memsize = "2048"
scsi0:0.present = "TRUE"
scsi0:0.fileName = "Ubuntu.vmdk"
ethernet0.present = "TRUE"
ethernet0.virtualDev = "e1000"
displayName = "Ubuntu"
guestOS = "ubuntu-64"
virtualHW.productCompatibility = "hosted"

Change the line with Ubuntu.vmdk to the actual file name of the Ubuntu image you just downloaded.

You can start the VM by double-clicking on the .vmx file you just created.

Change the amount of memory or the number of processors you want to assign to the VM in the Virtual Machine settings in VMWare Player.

The login data for VMs downloaded from osboxes is:
username: osboxes
password: osboxes.org

Once you started the VM and logged in, continue as if you would run Ubuntu natively.

Windows Subsystem for Linux

The Windows Subsystem for Linux (WSL) was not very interesting for serious development in its first version. Many of the shortcomings (like tediously slow "fork" and "stat") have been fixed in WSL2 which was released together with Windows 10 Update 2004.

To install WSL2 on Windows, follow the instructions by Microsoft.

WSL2 is basically a virtual machine running the Linux kernel that is more closely integrated into Windows. But it also has some limitations (see below).

Again it is possible to choose from several different Linux distributions. But for reasons already mentioned, you should choose Ubuntu.

Once you logged in to Ubuntu on WSL, continue as if you would run Ubuntu natively.

WSL (or WSL2) does not contain an X server. The X server on Linux is necessary to present program windows to the users. So by default, WSL is only a command line interface. You can start that command line interface with the "Ubuntu" shortcut in the start menu.

If you want to run the Octave GUI, you can install an X server. There are several you can choose from. One of them is VcXsrv. When you start VcXsrv, choose "Multiple Windows", "Start no client", deselect "Native opengl", and select "Disable access control" to be able to use the X server from WSL. Additionally, append the following lines to your .bashrc file in the home directory on the WSL Ubuntu:

export DISPLAY=$(awk '/nameserver / {print $2; exit}' /etc/resolv.conf 2>/dev/null):0
export LIBGL_ALWAYS_INDIRECT=1

You can access that file via the share "\\wsl$\Ubuntu\home\username\.bashrc" (where "Ubuntu" is the name of the distribution you installed and "username" is your username on that distribution.

Because of the basic lack of a graphical user interface (even if somewhat mitigated with the X server), using WSL(2) is not recommended for beginners.


Footnotes