Building on Ubuntu Virtual Machine: Difference between revisions

From Octave
Jump to navigation Jump to search
m (Added descriptions.)
m (Fix Octave command)
 
(12 intermediate revisions by 2 users not shown)
Line 1: Line 1:
This page contains instructions on how to build Octave in an Ubuntu virtual machine in a Windows Host.
This page contains instructions on how to build Octave in an Ubuntu virtual machine in a Windows Host. There are multiple approaches to this.
 
In addition to the VirtualBox approach described below, it is possible to use the Windows Subsystem for Linux [https://docs.microsoft.com/en-us/windows/wsl/about]. On windows 10 wsl2 can be used, which for graphical output requires installing an X11 or VNC client on windows, and setting up a virtual X11 display on the virtual linux system. On windows 11 wslg is available with comes with an integrated X11 client and ready to use X11 display. Wsl and wsl2 have near native unix performance. Ubuntu is one of the available OS-es to install for wsl2/wslg, and once that is installed the instructions as for the Ubuntu installed with VirtualBox apply.


This page is both concise and self-contained to allow beginners to quickly develop code for Octave. The libraries and instructions have been tested in Ubuntu 20.04.
This page is both concise and self-contained to allow beginners to quickly develop code for Octave. The libraries and instructions have been tested in Ubuntu 20.04.
= Virtualbox =
= VirtualBox =
# Download Virtualbox from [https://www.virtualbox.org/ virtualbox.org], install.
: 1. Create VM.
# Download Ubuntu Desktop iso from [https://ubuntu.com/download/desktop ubuntu.com].
## Download VirtualBox from [https://www.virtualbox.org/ virtualbox.org], install.
# Create VM.
## Download Ubuntu Desktop iso from [https://ubuntu.com/download/desktop ubuntu.com].
## Start VirtualBox. In Oracle VM VirtualBox Manager, Select: Machine -> New. In Name, put: OctaveDev; Type: Linux; Version: Ubuntu (64-bit). Adjust Memory size to half of what is available. For example, if 16384 MB are available, type 8192. In Hard disk, select: Create a virtual hard disk now. Click Create.
## Start VirtualBox. In 'Oracle VM VirtualBox Manager', Select: Machine -> New. In Name, put: OctaveDev; Type: Linux; Version: Ubuntu (64-bit). Adjust 'Memory size' to half of what is available. For example, if 16384 MB are available, type 8192. In 'Hard disk', select: 'Create a virtual hard disk now'. Click Create.
## In Create Virtual Hard Disk window, under File size: 50 GB; Hard disk file type: VDI; Storage on physical hard disk: Dynamically allocated. Click Create.
## In 'Create Virtual Hard Disk' window, under 'File size': 50 GB; 'Hard disk file type': VDI; 'Storage on physical hard disk': Dynamically allocated. Click Create.
## Back to Oracle VM VirtualBox Manager, select OctaveDev, click on Settings. In System, select Processor tab. Adjust the number of CPUs to half of what is available, since this will speed up the compilation and response of the VM. For example, if you have 8 cores, select 4. Click OK. In Storage, under 'Controller: IDE', select Empty. Under Attributes, click on the disk icon. Browse and select the iso file previously downloaded. Click OK.
## Back to 'Oracle VM VirtualBox Manager', select OctaveDev, click on Settings. In System, select Processor tab. Adjust the number of CPUs to half of what is available, since this will speed up the compilation and responsiveness of the VM. For example, if you have 8 cores, select 4. In Storage, under 'Controller: IDE', select Empty. Under Attributes, click on the disk icon (shown on the right), then select 'Choose a disk file ...'. Browse and select the iso file previously downloaded. Click OK.
## Double click the newly created VM to start it. Follow the prompts to install the operating system. Don't forget to add a username and a password. This tutorial has the username as 'ubuntuuser'.
## Double click the newly created VM to start it. Follow the prompts to install the operating system. Don't forget to add a username and a password. This tutorial has the username as 'ubuntuuser'.
## After the installation procedure is finished: restart the Ubuntu system, open a terminal by pressing {{key press|Ctrl|Alt|t}}. Issue the following commands : $ sudo apt-get update; $sudo apt-get install gcc make perl
## In the VirtualBox window select Devices, then 'Insert Guest Additions CD Image...', and follow the prompts. After the installation is finished, restart the Ubuntu system.
= Dependencies =
= Dependencies =
: 4. Install dependencies.
: 2. Install dependencies.
## In the Ubuntu system, open a terminal by pressing {{key press|Ctrl|Alt|t}}. Issue the following commands (tested only on Ubuntu 20.04):
In the Ubuntu system, open a terminal by pressing {{key press|Ctrl|Alt|t}}. Issue the following commands (tested only on Ubuntu 24.04):
     $sudo apt-get update
     $ sudo apt-get update
     $sudo apt-get install build-essential mercurial gcc g++ gfortran make libblas-dev liblapack-dev epstool transfig libglpk-dev libreadline-dev llvm-dev lpr texinfo pstoedit liboctave-dev libqhull-dev libqrupdate-dev libsuitesparse-dev texlive libxft-dev autoconf automake bison flex gperf gzip icoutils libtool perl rsync tar libpcre3-dev libarpack2-dev libcurl4-openssl-dev libfftw3-dev libfltk1.3-dev libfontconfig1-dev libfreetype6-dev libgl2ps-dev gnuplot-x11 libgraphicsmagick++1-dev libhdf5-dev libsndfile1-dev libgl1-mesa-dev libosmesa6-dev portaudio19-dev zlib1g-dev libegl1-mesa-dev libgles2-mesa-dev libwayland-client0 libwayland-cursor0 libwayland-dev libwayland-egl1 libwayland-egl1-mesa libwayland-server0 libwayland-bin libwayland-client0 texlive-plain-generic librsvg2-bin openjdk-14-jdk openjdk-14-jre openjdk-14-jre-headless openjdk-14-jdk-headless qttools5-dev-tools qtbase5-dev qtbase5-dev-tools qttools5-dev libqscintilla2-qt5-dev libqt5sql5-sqlite libqt5webchannel5 libqt5webkit5 libqt5concurrent5 libqt5designer5 libqt5designercomponents5 libqt5help5 libqt5positioning5 libqt5quickwidgets5 libqt5sensors5 libqt5sql5 qt5-assistant qt5-qmake qt5-qmake-bin libqt5core5a libqt5network5 libqt5gui5 libqt5opengl5 libqt5opengl5-dev git rapidjson-dev libsundials-dev doxygen texlive-latex-extra graphviz
     $ sudo apt-get install build-essential mercurial gcc g++ gfortran make libblas-dev liblapack-dev epstool transfig libglpk-dev libreadline-dev llvm-dev lpr texinfo pstoedit libqhull-dev libqrupdate-dev libsuitesparse-dev texlive libxft-dev autoconf automake bison flex gperf gzip icoutils libtool perl rsync tar libpcre3-dev libarpack2-dev libcurl4-openssl-dev libfftw3-dev libfltk1.3-dev libfontconfig1-dev libfreetype-dev libgl2ps-dev gnuplot-x11 libgraphicsmagick++1-dev libhdf5-dev libsndfile1-dev libgl1-mesa-dev libosmesa6-dev portaudio19-dev zlib1g-dev libegl1-mesa-dev libgles2-mesa-dev libwayland-dev openjdk-21-jdk openjdk-21-jre openjdk-21-jre-headless openjdk-21-jdk-headless qttools5-dev-tools qtbase5-dev qtbase5-dev-tools qttools5-dev libqscintilla2-qt5-dev libqt5opengl5-dev git rapidjson-dev libsundials-dev doxygen texlive-latex-extra graphviz librsvg2-bin
: 5. Mercurial
: 3. Mercurial.
From the page [[Mercurial]], follow the steps under the section 'Example Mercurial configuration'.
From the page [[Mercurial]], follow the steps under the section 'Example Mercurial configuration'.
= Build directory =
= Build Directory =
: 6. Setup build directory
: 4. Setup the build directory.
     $ mkdir -p /home/ubuntuuser/projects/octave_src
     $ mkdir -p /home/ubuntuuser/projects/octave_src
     $ cd /home/ubuntuuser/projects/octave_src
     $ cd /home/ubuntuuser/projects/octave_src
Line 25: Line 29:
     $ ./bootstrap --force
     $ ./bootstrap --force
     $ mkdir -p bld_dir; cd bld_dir;
     $ mkdir -p bld_dir; cd bld_dir;
: 7. Configure
: 5. Configure.
     $ rm * -r -f; date; ../configure -v --prefix=/home/ubuntuuser/projects/octave_src/octave_install >& configure.out; date; paplay /usr/share/sounds/gnome/default/alerts/glass.ogg
    $ cd /home/ubuntuuser/projects/octave_src/octave/bld_dir
     $ rm * -r -f; ../configure -v --prefix=/home/ubuntuuser/projects/octave_src/octave_install >& configure.out;
To check if any library has not been found by the configure script:
To check if any library has not been found by the configure script:
     $ grep -i "library not found" configure.out
     $ grep -i "library not found" configure.out
: 8. Make:
: 6. Make.
     $ date; make -j -l2  V=1 >& make.out; date; paplay /usr/share/sounds/gnome/default/alerts/glass.ogg
     $ make -j 4 V=1 >& make.out
= Debug =
= Debug =
: 9. Debugging
: 7. Debugging.
Note: The option ‘--enable-address-sanitizer-flags’ breaks the build, so it can be removed.
Note: The option ‘--enable-address-sanitizer-flags’ breaks the build, so it was removed.
From [[Debugging Octave]]:
From [[Debugging Octave]]:
     $ cd /home/ubuntuuser/projects/octave_src/octave
     $ cd /home/ubuntuuser/projects/octave_src/octave
     $ mkdir -p dbg_bld_dir; cd dbg_bld_dir;
     $ mkdir -p dbg_bld_dir; cd dbg_bld_dir;
     $ rm * -r -f; date; time ../configure -v --prefix=/home/ubuntuuser/projects/octave_src/octave_install_dbg FFLAGS=-g CFLAGS=-g CXXFLAGS=-g >& configure.out; date; paplay /usr/share/sounds/gnome/default/alerts/glass.ogg
     $ rm * -r -f; ../configure -v --prefix=/home/ubuntuuser/projects/octave_src/octave_install_dbg FFLAGS=-g CFLAGS=-g CXXFLAGS=-g >& configure.out
     $ date; time make -j -l2  V=1 >& make.out; date; paplay /usr/share/sounds/gnome/default/alerts/glass.ogg
     $ make -j 4 V=1 >& make.out
     $ echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
     $ echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
     $ ./run-octave --gui
     $ ./run-octave --gui
     >> system (sprintf ("gnome-terminal --command 'gdb -p %d'", getpid ()), "async");
Then run the following command in Octave command line:
Apply a breakpoint at the function edit_variable (which will be hit in another thread from the current one, so apply breakpoint for all threads).
     >> system (sprintf ("gnome-terminal --command 'gdb -p %d'", getpid ()), 0, "async");
     (gdb) thread apply all break variable-editor.cc:1154
In the new terminal window that appears: First set pagination off, then apply a breakpoint at the function edit_variable (which will be hit in another thread from the current one, so apply breakpoint for all threads), then type 'c' to continue.
Continue.
    (gdb) set pagination off
     (gdb) thread apply all break variable_editor::edit_variable
    (gdb) c
In Octave's command line:
     >> a = [1 2]
     >> a = [1 2]
In Octave, double click ‘a’. Now gdb should be at the breakpoint. Now backtrace 10 to show the calling information:
Still in Octave, locate the Workspace widget (which lists all the current variables). Double-click on the variable ‘a’. Nothing happens in Octave, but if you switch to gdb, you can see that the program stopped at the breakpoint. Now backtrace 10 to show the calling information:
     (gdb) backtrace 10
     (gdb) backtrace 10
Apply a breakpoint at the function variable_editor_model::create (which will be hit in another thread from the current one, so apply breakpoint for all threads).
To disable breakpoints and continue running the program:
     (gdb) thread apply all break variable-editor-model.cc:928
    (gdb) disable breakpoints
= Save and Patch
     (gdb) c
: 10. Save your work and send patch
= Save and Patch =
: 8. Save your work and send patch.
To save your changes to a single file:
To save your changes to a single file:
     $ cd /home/ubuntuuser/projects/octave_src/octave
     $ cd /home/ubuntuuser/projects/octave_src/octave
     $ hg commit -m "Description about the changes you have made."
     $ hg commit -m "Description about the changes you have made."
     $ hg export --git > ../yourwork_date.diff
     $ hg export --git > ../yourwork_date.diff
If you have made multiple commits, export all the revisions:
If you have made multiple commits, export all the revisions that you have made:
     $ hg export --git -r 28648:28649 > ../yourwork_date.diff
     $ hg export --git -r 28648:28649 > ../yourwork_date.diff
To save your changes and send a patch ([https://octave.org/doc/v4.0.1/Basics-of-Generating-a-Changeset.html Basics of Generating a Changeset]):
To save your changes and send a patch ([https://octave.org/doc/v4.0.1/Basics-of-Generating-a-Changeset.html Basics of Generating a Changeset]):

Latest revision as of 15:54, 24 June 2024

This page contains instructions on how to build Octave in an Ubuntu virtual machine in a Windows Host. There are multiple approaches to this.

In addition to the VirtualBox approach described below, it is possible to use the Windows Subsystem for Linux [1]. On windows 10 wsl2 can be used, which for graphical output requires installing an X11 or VNC client on windows, and setting up a virtual X11 display on the virtual linux system. On windows 11 wslg is available with comes with an integrated X11 client and ready to use X11 display. Wsl and wsl2 have near native unix performance. Ubuntu is one of the available OS-es to install for wsl2/wslg, and once that is installed the instructions as for the Ubuntu installed with VirtualBox apply.

This page is both concise and self-contained to allow beginners to quickly develop code for Octave. The libraries and instructions have been tested in Ubuntu 20.04.

VirtualBox[edit]

1. Create VM.
    1. Download VirtualBox from virtualbox.org, install.
    2. Download Ubuntu Desktop iso from ubuntu.com.
    3. Start VirtualBox. In 'Oracle VM VirtualBox Manager', Select: Machine -> New. In Name, put: OctaveDev; Type: Linux; Version: Ubuntu (64-bit). Adjust 'Memory size' to half of what is available. For example, if 16384 MB are available, type 8192. In 'Hard disk', select: 'Create a virtual hard disk now'. Click Create.
    4. In 'Create Virtual Hard Disk' window, under 'File size': 50 GB; 'Hard disk file type': VDI; 'Storage on physical hard disk': Dynamically allocated. Click Create.
    5. Back to 'Oracle VM VirtualBox Manager', select OctaveDev, click on Settings. In System, select Processor tab. Adjust the number of CPUs to half of what is available, since this will speed up the compilation and responsiveness of the VM. For example, if you have 8 cores, select 4. In Storage, under 'Controller: IDE', select Empty. Under Attributes, click on the disk icon (shown on the right), then select 'Choose a disk file ...'. Browse and select the iso file previously downloaded. Click OK.
    6. Double click the newly created VM to start it. Follow the prompts to install the operating system. Don't forget to add a username and a password. This tutorial has the username as 'ubuntuuser'.
    7. After the installation procedure is finished: restart the Ubuntu system, open a terminal by pressing Ctrl+Alt+t. Issue the following commands : $ sudo apt-get update; $sudo apt-get install gcc make perl
    8. In the VirtualBox window select Devices, then 'Insert Guest Additions CD Image...', and follow the prompts. After the installation is finished, restart the Ubuntu system.

Dependencies[edit]

2. Install dependencies.

In the Ubuntu system, open a terminal by pressing Ctrl+Alt+t. Issue the following commands (tested only on Ubuntu 24.04):

   $ sudo apt-get update
   $ sudo apt-get install build-essential mercurial gcc g++ gfortran make libblas-dev liblapack-dev epstool transfig libglpk-dev libreadline-dev llvm-dev lpr texinfo pstoedit libqhull-dev libqrupdate-dev libsuitesparse-dev texlive libxft-dev autoconf automake bison flex gperf gzip icoutils libtool perl rsync tar libpcre3-dev libarpack2-dev libcurl4-openssl-dev libfftw3-dev libfltk1.3-dev libfontconfig1-dev libfreetype-dev libgl2ps-dev gnuplot-x11 libgraphicsmagick++1-dev libhdf5-dev libsndfile1-dev libgl1-mesa-dev libosmesa6-dev portaudio19-dev zlib1g-dev libegl1-mesa-dev libgles2-mesa-dev libwayland-dev openjdk-21-jdk openjdk-21-jre openjdk-21-jre-headless openjdk-21-jdk-headless qttools5-dev-tools qtbase5-dev qtbase5-dev-tools qttools5-dev libqscintilla2-qt5-dev libqt5opengl5-dev git rapidjson-dev libsundials-dev doxygen texlive-latex-extra graphviz librsvg2-bin
3. Mercurial.

From the page Mercurial, follow the steps under the section 'Example Mercurial configuration'.

Build Directory[edit]

4. Setup the build directory.
   $ mkdir -p /home/ubuntuuser/projects/octave_src
   $ cd /home/ubuntuuser/projects/octave_src
   $ hg clone http://www.octave.org/hg/octave octave
   $ cd octave
   $ ./bootstrap --force
   $ mkdir -p bld_dir; cd bld_dir;
5. Configure.
   $ cd /home/ubuntuuser/projects/octave_src/octave/bld_dir
   $ rm * -r -f; ../configure -v --prefix=/home/ubuntuuser/projects/octave_src/octave_install >& configure.out;

To check if any library has not been found by the configure script:

   $ grep -i "library not found" configure.out
6. Make.
   $ make -j 4 V=1 >& make.out

Debug[edit]

7. Debugging.

Note: The option ‘--enable-address-sanitizer-flags’ breaks the build, so it was removed. From Debugging Octave:

   $ cd /home/ubuntuuser/projects/octave_src/octave
   $ mkdir -p dbg_bld_dir; cd dbg_bld_dir;
   $ rm * -r -f; ../configure -v --prefix=/home/ubuntuuser/projects/octave_src/octave_install_dbg FFLAGS=-g CFLAGS=-g CXXFLAGS=-g >& configure.out
   $ make -j 4 V=1 >& make.out
   $ echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
   $ ./run-octave --gui

Then run the following command in Octave command line:

   >> system (sprintf ("gnome-terminal --command 'gdb -p %d'", getpid ()), 0, "async");

In the new terminal window that appears: First set pagination off, then apply a breakpoint at the function edit_variable (which will be hit in another thread from the current one, so apply breakpoint for all threads), then type 'c' to continue.

   (gdb) set pagination off
   (gdb) thread apply all break variable_editor::edit_variable
   (gdb) c

In Octave's command line:

   >> a = [1 2]

Still in Octave, locate the Workspace widget (which lists all the current variables). Double-click on the variable ‘a’. Nothing happens in Octave, but if you switch to gdb, you can see that the program stopped at the breakpoint. Now backtrace 10 to show the calling information:

   (gdb) backtrace 10

To disable breakpoints and continue running the program:

   (gdb) disable breakpoints
   (gdb) c

Save and Patch[edit]

8. Save your work and send patch.

To save your changes to a single file:

   $ cd /home/ubuntuuser/projects/octave_src/octave
   $ hg commit -m "Description about the changes you have made."
   $ hg export --git > ../yourwork_date.diff

If you have made multiple commits, export all the revisions that you have made:

   $ hg export --git -r 28648:28649 > ../yourwork_date.diff

To save your changes and send a patch (Basics of Generating a Changeset):

   $ cd /home/ubuntuuser/projects/octave_src/octave
   $ hg commit -m "Description about the changes you have made."
   $ hg export -o ../yourwork_date.diff tip

If you added binary files such as png files, use --git option in export:

   $ hg export --git -o ../yourwork_date.diff tip