Setup ITK

Hello, i want to setup ITK using cmake and Visual studio 2019 Community edition. I want to install ITK so that I can create code that can be compiled and create exe that contain all the needed libraries and be able to execute the exe file in each computer that may not have ITK installed. How can I do it?

Thank you in advance,
Constantinos Spanakis

Build ITK as static libraries.

When configuring ITK, make sure that BUILD_SHARED_LIBS is OFF. It should be OFF by default. Then compile your program normally - the executable should be big because it has needed parts of ITK embedded in it.

1 Like

Ok. I have a few questions.

  1. When I compile ITK.sln in visual studio, shall I compile it using debug mode or release mode?

  2. If i I want to create a program that embeds ITK libraries, should it be compiled in Visual studio in debug mode or release mode?

Normally, multiple configurations are compiled. I usually compile Debug and RelWithDebInfo. Static libraries work with all configurations.

Visual Studio’s limitation is that you cannot run Debug version of computers without Visual Studio installed on them, so you should compile in Release or RelWithDebInfo mode if you want to redistribute your program.

This means that as long as a PC has Visual Studio installed, it doesn’t matter whether the code that uses itk and itk itself are compiled in debug or release mode.

Am I right?

Yes. Otherwise it cannot be debug.

In the case where we have windows but not Visual studio installed, what can be done?

Use RelWithDebInfo configuration. It should have some debug symbols (some will be optimized away). But if there is no debugger on the target computer, why do debug symbols matter to you?