Personal tools
You are here: Home / cmgui / Wiki / Linux instructions using make
Log in

Forgot your password?

Linux instructions using make

This is a guide to building cmgui from source on linux. (For building on windows see Windows instructions ). If all goes smoothly it should take less than an hour and a half to build cmgui from source the first time. Much of that time will be spent twiddling your thumbs waiting for things to download or compile.

Some provisos: I am also assuming that you a trying to compile on a 32 bit linux machine. Which gives us the string 'i686-linux' as your architecture string.

If you have access to the CMISS server you can skip some steps by copying precompiled binaries/libraries directly. I have used 'scp' for file transfer, although if you can mount /hpc/cmiss from bioeng22 on you computer you can just use 'cp'.

  • Step 0: Install any missing packages

You will need certain packages installed to build cmgui. A basic ubuntu installation is unlikely to have all the required packages installed by default. Here is a list of commands I ran to install required packages that I was missing when building cmgui from source on a basic ubuntu installation:

sudo apt-get install libmotif-dev
sudo apt-get install libmotif3
sudo apt-get install subversion
sudo apt-get install build-essential
sudo apt-get install libgtk2.0-dev
sudo apt-get install libglut3-dev
sudo apt-get install libxp-dev
sudo apt-get install libxmu-dev
sudo apt-get install libgtkglext1-dev
sudo apt-get install libxxf86vm-dev

Or in one massive hit:

sudo apt-get install libmotif-dev libmotif3 subversion \
build-essential libgtk2.0-dev libglut3-dev libxp-dev \
libxmu-dev libgtkglext1-dev libxxf86vm-dev cmake

If you don't have root access or are unfamiliar with installing packages get your sysadmin to install these for you. Note that you can check which packages and what versions are installed on your system using 'dpkg -l'. Piping the command through grep can be convenient to check on several packages, eg 'dpkg -l | grep libmotif'.

Part of the build process also uses CMake, please also make sure you have CMake install:

sudo apt-get install cmake
  • Step 1: check openmotif is installed

If you ran the commands in Step 0 it should be installed. Note that you will need to have openmotif as lesstif is no good (the uil compiler in lesstif is broken). To check whether openmotif is installed see if you have the motif library file by typing:


If you do not have root access you may need to sudo this command 'sudo locate'. If nothing comes up have a look in /usr/lib to see if it is there (the locate database may not have updated yet). You can install openmotif via apt-get. If you need more info on openmotif see

The latest version of openmotif is 2.3.0 beta which provides better support for wide character sets (unicode etc) than previous versions. If you have an earlier version of openmotif you may need to change your LANG environment variable to use ascii rather than utf-8. To do this in a shell:

export LANG=en_NZ

Consider adding this to your .profile file.

Note that eventually the motif version of cmgui will be superceded by the wx widgets version.

  • Step 2: set up an svn client

You will need a subversion client, normally called svn on linux. To check if you have one installed type:

svn --help

You should see an appropriate help message if you have svn installed. Our server is currently version 1.4.x

  • Step 3: create a cmiss root directory

A root directory for cmiss needs to be made where all code and libraries will be placed. You can create the cmiss directory wherever you wish. Tocreate one in the default home directory one up a shell and type:

cd ~
mkdir cmiss

You also need to set up an environment variable specifying the location of cmiss root and your bioeng username (replace 'bob' with your username), the easiest way is to do this in your .profile file. Edit your .profile file to include the line:

export CMISS_ROOT=~/cmiss

Now start up a new bash shell or source your .profile file. Some people will have a ~/.bash_profile file that calls ~/.bashrc, or vice versa, if you do put the above line in your ~/.bashrc file

  • Step 4: check out the source from subversion

Assuming you have a subversion client you can check out cmgui source:

svn checkout cmgui

Note this is not all the code as you will also need various other libraries that cmgui depends on. These following libraries are required:

  • perl_interpreter
  • third_party
  • itk
  • mesa (if your OpenGL headers don't match)

Instructions on setting these libraries up are given below.

  • Step 5: perl_interpreter

For building the perl interpreter from source follow Building the perl interpreter libraries. Be aware that if you build your own shared library based perl interpreter (which is probably what building from source will do) means that the cmgui you make will only run on your computer and others that have a binary compatible perl shared library. The CMISS server builds actually includes bindings to many different version of perl libraries and a static fallback perl so that the executable will still function even if the end user has no perl installed.

If you have access to the CMISS server you can do the following

Copy over the appropriate lib files for your operating system and the source header file. Someone with username bob on an i686 linux system would do:

cd $CMISS_ROOT/perl_interpreter
mkdir lib
scp -r ${CMISS_USERNAME} lib
mkdir source
scp ${CMISS_USERNAME} source
  • Step 6: third_party

Get the third_party libraries:

svn checkout third_party

Known issue: The version of libxml2 included in the checkout may be outdated. Check in the folder $CMISS_ROOT/third_party/libxml2. Version 2.6.30 did not build in Ubuntu 8.10. The latest version can be downloaded from Extract the tar.gz into $CMISS_ROOT/third_party/libxml2/, keeping the files in its libxml2-(version) folder, e.g. $CMISS_ROOT/third_oart/libxml2/libxml2-2.7.2.

Next, edit the Makefile in $CMISS_ROOT/third_party/libxml2/. Alter the first line to update your libxml2 version, e.g.:

VERSION = libxml2-2.7.2

Save, close, and finally:

cd $CMISS_ROOT/third_party
  • Step 7: itk

Cmgui is currently tested against InsightToolkit-3.12.0 version of the itk library. To build the itk library do the following:

cd $CMISS_ROOT/third_party/insighttoolkit
tar -xzf InsightToolkit-3.12.0.tar.gz

InsightToolkit uses cmake to configure the build, under linux you can use the ncurses version ccmake. To configure the build:

mkdir build
cd build
ccmake ../InsightToolkit-3.12.0

Note: you can have the build directory anywhere you like, just give ccmake the relative path between your build directory and the source tree as the first argument. But don't build in the source tree, anywhere but there. Type "c" to run configure. Then configure the build with:

  • CMAKE_INSTALL_PREFIX /home/bob/cmiss/third_party/i686-linux (which should be equivalent to $CMISS_ROOT/third_party/i686-linux)

Then type "c" to configure the changes and when this is complete type "g" to generate makefiles and exit. Then run make and make install:

make install

If you have access to the CMISS server you can get the appropriate itk code for your os (eg i686-linux) directly:

mkdir -p itk/i686-linux
scp -r ${CMISS_USERNAME} itk/i686-linux
scp -r ${CMISS_USERNAME} itk/i686-linux
  • Step 8: wxWidgets

wxWidgets will eventually replace the motif version of cmgui, providing an environment which should run on different operating systems. It is currently still possible to build the motif version. If you wish to build the wxWidgets version you will need to do the following.

Download the wxWidgets from, click on the wxAll option (e.g., wxWidgets-2.8.9.tar.gz). Then do:

tar -xzf /whereever/you/saved/the/file/wxWidgets-2.8.9.tar.gz
cd wxWidgets-2.8.9
mkdir buildgtk
cd buildgtk

Now you need to build the static libaries for the debug version, specifying the location of the target/install directory using the prefix flag:

../configure --disable-shared --enable-debug --with-opengl --prefix=$CMISS_ROOT/wxWidgets
make install

If you get an error building wxWidgets under Ubuntu Karmic Koala check out the following bug: - patching the file works.

If you like to keep a tidy house run:

make distclean

Now build the static libaries for the optimised version, specifying the location of the target directory using the prefix flag:

../configure --disable-shared --disable-debug --with-opengl --prefix=$CMISS_ROOT/wxWidgets
make install

We are building wxWidgets and expat statically to try and reduce the number of runtime dependencies for the built executable.

For more information or if you have problems see Building Cmgui with wxWidgets

  • Step 9: mesa

Mesa is required if you intend to do testing with your Cmgui build. Mesa may be required if the compiler is trying to link against openGL headers that do not match. Skip this step and if your code does not compile come back to it. If you don't have mesa already installed then go to and download the latest stable release.

If you have access to bioeng network you can:

mkdir -p mesa/lib
mkdir mesa/include
scp -r ${CMISS_USERNAME} mesa/lib
scp -r ${CMISS_USERNAME} mesa/include
  • Step 10: compile cmgui

Now you are ready to make cmgui:

cd $CMISS_ROOT/cmgui

By default it will build cmgui-motif-debug and place it in a bin directory under a subdirectory of the operating system name. Check that compilation has created an executible by looking at this directory:

ls $CMISS_ROOT/cmgui/bin/i686-linx

You should see an executable file 'cmgui-motif-debug'

You can specify other targets such as

  • cmgui-motif (optimised version)
  • cmgui-gtk (gtk toolkit version)
  • cmgui-console (no graphics, just command line)
  • cmgui-motif-debug-memorycheck (keeps track of all memory access and deaccess and reports leaks etc.)

If you wish to compile the wxWidgets version use:

cd $CMISS_ROOT/cmgui
make cmgui-wx-debug WX_DIR=${CMISS_ROOT}/wxWidgets/bin/

(If compiling the wx version a lot, you may want to set the WX_DIR variable in your cmgui makefiles. Edit '$CMISS_ROOT/cmgui/source/developer.Makefile', and add a line like 'DEVELOPER_OPTIONS += WX_DIR=/home/bob/cmiss/wxWidgets/bin/').

Known issue on Ubuntu Karmic Koala: /usr/bin/ld fails when compiling cmgui. Binutils 2.20 is the guilty package, downgrade this to 2.18 for it to work. Download the downgraded package from and run 'sudo dpkg -i binutils_2.18.1~cvs20080103-7_i386.deb' - Duane Malcolm (26/11/2009)

If you encounter a linker problem(s) try applying one (or both) of these patches depending on the missing dependency(ies).

Hopefully it will be obvious which one is needed

  • Cross compiling

If you are using the Cross compilers environment from /hpc/cmiss you MUST have CMISS_ROOT set to /hpc/cmiss for the cmgui makefile to set up various variables correctly for the cross compile environment.