Build and install CamiTK on Windows

How to build and install the CamiTK on Windows

Now that you have done all the hard work of installing the toolchain and dependency, this step will be very easy!

Warning: re-installing camitk

If you had an existing installation of CamiTK in a different directory, you may still have some files in AppData (usually ̀C:\Users\<username>\AppData\Roaming\CamiTK). Remove this CamiTK directory if it exists, as it might contain erroneous paths that will interfere with the next steps.

Get the source code

You need to choose between:

Get CamiTK stable

Open a windows cmd prompt and type:

:: go to the top level directory of your install drive
%CAMITK_INSTALL_DRIVE%
cd %CAMITK_INSTALL_ROOT%\

:: Download the latest stable source
curl -L https://gricad-gitlab.univ-grenoble-alpes.fr/CamiTK/CamiTK/-/archive/5.2.0/CamiTK-5.2.0.zip --output %CAMITK_INSTALL_ROOT%\downloads\CamiTK-5.2.0.zip

:: extract the source
7z x %CAMITK_INSTALL_ROOT%\downloads\CamiTK-5.2.0.zip -o%CAMITK_INSTALL_ROOT%\src

Now jump directly to the build and install section.

Get CamiTK develop

To get CamiTK develop, you need to clone CamiTK from the develop branch from the git repository.

Open a windows cmd prompt and type:

:: go to the top level directory of your install directory
%CAMITK_INSTALL_DRIVE%
cd %CAMITK_INSTALL_ROOT%\
cd %CAMITK_INSTALL_ROOT%\src

:: clone the develop branch in the src directory
git clone -b develop --single-branch https://gricad-gitlab.univ-grenoble-alpes.fr/CamiTK/CamiTK.git

Type git pull in the %CAMITK_INSTALL_ROOT%\src\camitk directory every so often in order to get the most recent develop version. It usually provides the latest bug fixes and new features!

In case you plan to contribute to the project, we recommend to can create an account or connect to our gitlab instance, add an ssh key to your account and then use the git protocol:

git clone git@gricad-gitlab.univ-grenoble-alpes.fr:CamiTK/CamiTK.git
git checkout develop

Cloning this way makes it easier to test branches, create new collaborative branches, and submit merge requests.

Build and install

Configure using CMake GUI

First run CMake GUI to configure your project for compilation:

  • In CMake GUI set the build and source directories. It is strongly advise to set the build directory to %CAMITK_INSTALL_ROOT%\build\camitk as it is consistent with what was done so far.
  • Click Configure
  • Choose the correct compiler and check options you want: to get the full CamiTK Community Edition, we recommend to check the three provided extension projects:
    • CEP_IMAGING: provides a DICOM support and useful image processing algorithms (Note that you need to have compiled ITK and GDCM to build CEP_IMAGING)
    • CEP_MODELING: provides Modeling Meta Language support for biomechanical models
    • CEP_TUTORIALS: provides code examples (for actions, components, viewers, libraries and applications)
    • For future installation you should also set the CMAKE_INSTALL_PREFIX to the directory where you want to install the CamiTK binaries.

We strongly recommend to set CMAKE_INSTALL_PREFIX to %CAMITK_INSTALL_ROOT%\install in order to keep everything consistent. If you leave the default value, you may get a setLocale error when building the install target due to the user not having enough rights to install into a protected directory.

  • After that click Configure again until there are no red highlights and you are satisfied with the choices you made
  • Click Generate to obtain Visual Studio files in your build directory

Unfortunately, there is one last problem due to a bug in ITK CMake configuration, that generates a mismatch between ITK and GDCM configuration on Windows. In order to fix this, open a command shell and type the following:

:: go to the CamiTK build directory of your install drive
%CAMITK_INSTALL_DRIVE%
cd %CAMITK_INSTALL_ROOT%\build\camitk

:: backup
cp imaging\components\dicom\component-dicom.vcxproj component-dicom-vcxproj-ori

:: remove the culprit (note: < and > have to be escaped in cmd shell using ^)
sed 's/\^<itkgdcmMSFF-4.13.lib\^>//g' component-dicom-vcxproj-ori > component-dicom-vcxproj-patched

:: copy patch in situ
cp component-dicom-vcxproj-patched imaging\components\dicom\component-dicom.vcxproj

Build and install using Visual Studio

Go to the build directory and double click on the camitkcommunityedition.sln file to open CamiTK Visual Studio solution.

  • Choose the Debug mode
  • Right click on the INSTALL project and select Build (this will install the debug version sometimes useful for debugging your own CEP)
  • Choose the Release mode
  • Right click on the INSTALL project and select Build

Check the installation

Run camitk-imp

After the compilation and installation, you can use CamiTK as a user (run an application provided by the community edition) or a developer (to develop your own CEP). Here is how to do with initial values for environment variables, adapt this with the choices you have made :

  • As a normal user: Binary executables are located in %CAMITK_INSTALL_ROOT%\install\bin. Just double-click on camitk-imp.exe or any other provided application (note that you need a command prompt to run camitk-config.exe which is a console application, see below).
  • As a CamiTK developer: Depending on your Visual Studio configuration (debug or release), configure the camitkcommunityedition solution property (right click on ALL BUILD\Properties\Configuration Properties\Debugging\Command) and add $(ProjectDir)/bin/camitk-imp-debug.exe or $(ProjectDir)/bin/camitk-imp.exe. You should also check that the Working Directory parameter is to $(ProjectDir). For debugging other targets, the Working Directory should be set to $(SolutionDir).

When you will later configure your CEP using the CMake GUI, you will have to set the CAMITK_DIR CMake variable to your installation directory (e.g., %CAMITK_INSTALL_ROOT%\install\). Once set, the CamiTK CMake macros should find everything they need to let you start your development.

Run camitk-config

Launch a new command shell and type:

%CAMITK_INSTALL_DRIVE%
cd %CAMITK_INSTALL_ROOT%\install\bin
camitk-config --config

This should print details information about camitk version, where camitk is looking for extensions (aka the extension repository), and the default installed extensions.

Where should I go next?

Start your development with CamiTK!