SimpleITK: compiling first C++ program

I managed to compile SimpleITK according to the instructions, and now I would like to start using it from C++.

I am looking for guidance on compiling one of the basic examples such as HelloWorld.cxx or SimpleGaussianFunctional.cxx from the command line (macOS). I see that there is an include folder, which contains the required headers, and I can use them. There is also a lib folder with many .a files, but I am not sure which to link with (and how) to compile successfully.

Could someone give a short example of a compilation command?

Also, is cmake a requirement for building programs that use SimpleITK? (I do not mean building SimpleITK itself, but using it from my own program.)

My ultimate goal is to expose a few filters to a high-level language that is not supported by SWIG. I am not very familiar with cmake, and combining it with the build system that comes with this high-level language would make things even more difficult. I would very much prefer to start with the simplest possible compiler command line that can get the HelloWorld.cxx example compiled and working.

If there is a documentation page that explains how to build my own programs with SimpleITK, please do let me know. After extensive searching, I was unable to find one.

It seems that if I include all the .a files from the lib directory, as well as the ITK-prefix/lib directory, then the executable is linked successfully, and it runs correctly. Is this a reasonable way of doing it?

I.e., compile with

c++ -std=c++11 someProg.cpp -I include/SimpleITK-1.1 lib/libSimpleITK*.a ITK-prefix/lib/*.a

That is correct. It can be a simple matter of including just the SimpleITK include directory and all the ITK/SimpleITK libraries. Now, SimpleITK and ITK have a lot of configuration options so they may depend on system headers or additional third party libraries and headers depending on how they are configured. SimpleITK as a reasonable “clean” interface, so this is a reasonable way to do things.

If you are able to use CMake, all this information is encoded into the configurations and exports. Since each library knows it dependencies, it may result in fewer libraries being used.