You are here

How to compile

To compile MedSquare, there are some basic steps:

Step 1: Download MedSquare's source code

MedSquare's code is hosted at SourceForge.net using git for versioning. Download it using the following command:

git clone git://medsquare.git.sourceforge.net/gitroot/medsquare/medsquare

Step 2: Obtain and compile its dependencies

In order to compile MedSquare, you first need to have the following libraries installed on your computer.

VTK must have been compiled with Qt and Python support. See instructions below to compile VTK with these requirements.

Also, MedSquare uses CMake (version 2.8 or newer - http://www.cmake.org/) to generate the necessary files for compilation (Makefile, Visual Studio solution etc.).

Specific instructions for Linux and Mac OSX

If your distribution provides in its package manager the libraries specified above in their correct versions (including VTK requirements), you can skip this section directly to Step 3. Otherwise, follow the steps below to compile the dependencies.

The libraries specified above depend upon:

  • A working C++ compiler (usually g++)
  • The Xrender and Xt libraries (and their headers, for compiling against them)
  • Python runtime and headers
  • Mesa's offscreen rendering and libGLU libraries (and their headers)

To install these dependencies on Ubuntu, for instance, run in your terminal:

sudo apt-get install c++ libxrender-dev python-dev libxt-dev libglu1-mesa-dev libosmesa6-dev

And, on Fedora, you can run:

sudo yum install gcc-c++ libXrender-devel python-devel libXt-devel mesa-libGLU-devel mesa-libOSMesa-devel

In Debian:

sudo apt-get install g++ libxi-dev libxft-dev libxrandr-dev libxrender-dev libxfixes-dev libxext-dev libxcursor-dev libx11-dev libfreetype6-dev libfontconfig1-dev make

It's also recommended that you install the curl program, so that you can use our scripts for downloading the remaining dependencies. There are three scripts: build.sh (inside the medsquare folder), install_devs.sh and standalone_install.sh  (inside the medsquare/install folder).

The build.sh script is used by our continuous integration server (see the Tests dashboard). It automatically downloads VTK, ITK, Qt, CMake, GDCM and GTest, compile them and install them in a medsquare directory inside the current user's home folder. It also compiles MedSquare and runs its automated tests.

The standalone_install.sh script is the most user-friendly way of installing MedSquare from the source code. This script will download and compile the sources for the major dependencies in a destination folder of your choosing.

The install_devs.sh script works in a similar way, but allows some customizations, such as choosing a different version of a library (not recommended) or choosing no version at all (in which case you must install the referred library by yourself). This script is aimed at the developers, to test new versions of dependencies.

If you want to compile VTK by yourself, you need to set these flags when configuring its compilation with CMake:

  • BUILD_SHARED_LIBS = ON
  • VTK_USE_QT = ON
  • VTK_WRAP_PYTHON = ON

After pressing the configuration key in ccmake (c), should appear the option VTK_USE_QVTK_QTOPENGL set it in ON.

Specific instructions for Windows using MinGW

To compile MedSquare on Windows using MinGW, you must install the following programs and libraries:

  • CMake (version 2.8 is recommended)
  • MinGW (use the mingw-get-inst-20100831 version that can be found here)
  • Qt for MinGW (you can download it here; ignore the warning about MinGW's version when installing it)

After downloading and installing these programs and libraries, you will need to compile VTK, ITK, GDCM and GTest.

Download and unzip each library. Then start by compiling VTK. Generate the Makefile for VTK with CMake, setting the following flags:

  • BUILD_SHARED_LIBS = ON
  • VTK_USE_QT = ON
  • VTK_WRAP_PYTHON = ON

When generating the compilation specifications with CMake, use the "MinGW Makefiles" generator, or the "Eclipse CDT 4 - MinGW Makefiles" generator if you plan to use Eclipse IDE for developing.

After doing that, open the command prompt, navigate to the folder where the Makefile was written by CMake and run

mingw32-make.exe

After that, generate the Makefile for ITK and compile it using the same procedure.

IMPORTANT: in order to compile ITK using MinGW, you need to manually patch the file itkConfigure.h generated by CMake. Find the following line:

#define CMAKE_NO_ANSI_STRING_STREAM

and comment it:

/* #define CMAKE_NO_ANSI_STRING_STREAM */

After compiling VTK and ITK, configure the compilation process for GDCM. You are going to need to provide the directory where you compiled VTK.

GDCM must be installed after compiled. To install it, run in the same folder you compiled it:

mingw32-make.exe install

After that, you need to configure and compile GTest. Generate a Makefile for it and run mingw32-make.txt inside the folder where you generated it.

Step 3: Compile and install MedSquare

Finally, you can compile MedSquare. Generate a Makefile using CMake. You are going to need to provide the directories where you have compiled VTK (flag VTK_DIR) and ITK (flag ITK_DIR), the directory where you have installed GDCM (more precisely, the folder lib/gdcm-2.0 inside it, to the flag GDCM_DIR) and the paths to GTest headers and two files generated by its compilation process. Follow the instructions below to configure GTest inside CMake:

Flag Value to fill in
GTEST_INCLUDE_DIR <folder where you unzipped GTest>/include
GTEST_LIBRARY <folder where you compiled GTest>/libgtest.dll
GTEST_MAIN_LIBRARY <folder where you compiled GTest>/libgtest_main.dll

After generating the Makefile for MedSquare, run mingw32-make.exe inside the folder where the Makefile was generated.