Skip to content

Build CemrgApp from Scratch

Jose Alonso Solis-Lemus edited this page Dec 3, 2024 · 19 revisions

This guide assumes you are either building CemrgApp without intending to make changes, or have write access to the CemrgApp repository. In those cases, you can clone the main CemrgApp repository.

If you want to contribute and don't have write access, please follow the instructions laid out in the Contribute to CemrgApp page of this wiki, which teaches you to fork CemrgApp to your account and branch off from development.

Table of Contents

Preliminaries

In all cases, Git, CMake, and Qt (Community Edition) are required. Installation changes depending on the operating system. Below are brief instructions for Ubuntu (which may also work for other Debian distros) and macOS.

We recommend using the latest versions of Qt that have been tested with CemrgApp. On macOS, this is Qt 5.15, and on Ubuntu, Qt 5.12.

Linux (Ubuntu 22.04)

Run sudo apt update before starting.

Install Git, CMake and (optionally, but highly recommended) the interactive CMake curses interface, CCMake:

sudo apt install -y git cmake cmake-curses-gui

Check that your version of CMake is > 3.22 using cmake --version.

You will need Qt v5.12.x. (These instructions were most recently tested with 5.12.10.) Qt can be obtained in several ways:

Once installed, set an environment variable to point to Qt

export QT=<path-to-qt>

You also need other libraries:

sudo apt install -y mesa-common-dev libglu1-mesa-dev libtbb libfontconfig1 libxt-dev libtiff5-dev doxygen libtbb2 libqt5widgets5 libfreetype-dev libasound2-dev

Check your gcc version using gcc --version. CemrgApp has been confirmed to work with gcc v11 (the default in Ubuntu 22.04). More recent versions may work, but have not been tested.

macOS

(Note: Build instructions have been tested on Intel-based Macs. There are known issues compiling some dependencies of CemrgApp on Apple Silicon-based Macs.)

You need to install the command line tools sudo xcode-select --install. Use homebrew as your package manager.

First, install current versions of git, cmake (v3.23 or newer) and Qt (v5.15.x)

brew install git cmake qt@5
export QT=$(brew --prefix)/opt/qt@5/

You also need to install other libraries:

brew install openlibm gmp libomp
export OpenMP_ROOT=$(brew --prefix)/opt/libomp
# brew link gmp # use this if it does not work

Clone the source code for MITK and CemrgApp

MITK is a tool for image analysis and processing. We build CemrgApp as an extension of MITK, keeping only the core modules and user interface bases, dispensing with everything else.

Currently, CemrgApp is built on top of MITK v2022.10. Download the code and prepare for the build process with the following commands:

cd /path/to/work_dir
 
# Download MITK and CemrgApp
git clone --branch v2022.10 --depth 1 https://github.com/MITK/MITK.git mitk
git clone --branch development https://github.com/OpenHeartDevelopers/CemrgApp.git cemrgapp
 
# Create build directory
mkdir build
 
# Set environment variables
export MITK_SOURCE=$PWD/mitk
export CEMRG_SOURCE=$PWD/cemrgapp
export CEMRG_BUILD=$PWD/build
## CMake configuration and build

Configuration of CMake is different between operating systems. In all cases, the CMake variable CMAKE_PREFIX_PATH to a specific path.

Move into the build directory, cd $CEMRG_BUILD, then do one of the following:

Configuration for Windows will be explained in the Appendix, at the bottom of this page.

Linux

cmake -DCMAKE_PREFIX_PATH=${QT}/5.12.10/gcc_64 -DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Release -DMITK_BUILD_ALL_PLUGINS=ON -DMITK_EXTENSION_DIRS=${CEMRG_SOURCE}/CemrgApp $MITK_SOURCE

Alternatively, you can use CCMake to set the options via the interactive interface. Run

ccmake -DCMAKE_PREFIX_PATH=$QT/5.12.10/gcc_64 $MITK_SOURCE

and set the remaining options using the CCMake user interface as described below.

macOS

ccmake -DCMAKE_PREFIX_PATH=$QT -DCMAKE_CXX_FLAGS="-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I$OpenMP_ROOT/include" -DCMAKE_C_FLAGS="-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I$OpenMP_ROOT/include" $MITK_SOURCE

Setting CMake variables

Press C to configure, then E when indicated. Press T to toggle ON the advanced configuration variables. Modify the following:

Variable Value
BUILD_TESTING OFF
CMAKE_BUILD_TYPE Release
MITK_EXTENSION_DIRS /path/to/work_dir/cemrgapp/CemrgApp
MITK_BUILD_ALL_PLUGINS ON

Note that the variable MITK_EXTENSION_DIRS points to the CemrgApp folder which is inside the CemrgApp repository.

Press C again to configure, then G to generate the project.

Build CemrgApp by running make from the build directory. (Run cd $C=BUILD if you are not already in that directory.) Using the -j<n> flag will speed up the build. <n> is the number of processors to build the application with, e.g.:

make -j4

Be patient! The build takes a long time, especially the first time.

If you run into problems, consider checking the Known Issues page.

Appendix. CMake configuration in Windows

In the CMake UI, add a new variable by pressing the plus button (+) and setting the CMAKE_PREFIX_PATH to $QT/5.12.10/msvc_17.