How to write implement Hello World from examples

Hello! I am a bit confused about when and where to be configuring and compiling ITK. I was under the impression that after compiling ITK once, I can then write my own separate code that utilizes ITK’s class structure, and never have to compile anything in relation to ITK again. Is that not true? I first implemented ccmake (which I assume configures ITK to be compiled), and then implemented the make command (which does the actual compiling), making sure that my source code is in a separate directory from the binary code. But after doing that, in order to run the “HelloWorld.cxx” example in Examples/Installation, do I need to compile ITK all over again? If so, in what directory would I want to do that in? And how would that be any different from the initial compilation?

Perhaps a broader question would be: where/how does ITK exist in my computer once it’s compiled? Does it become a library that I can reference, or is it code that I have to keep compiling with the code I will be producing myself?

During CMake configure step for ITK, there are many options. One of them is BUILD_EXAMPLES, and it is off by default. You should turn it on, configure and generate again in CMake, then make. That should produce HelloWorld.exe in your ITK-build/bin/ directory.

ITK exists as a set of compiled libraries (one of which is ITKCommon.dll), as well as header-only libraries which are compiled together with the program which uses them. So if you want to use if from your own program, you need to link to ITK. It is best to use CMake for that.

1 Like