[ITK Community] How to recompile only one module

Brian Helba brian.helba at kitware.com
Fri Nov 15 05:04:19 EST 2013


Hi Michka,

I think I'm understanding some of your issues. Recall that in C++,
templated classes are compiled only on actual instantiation, otherwise they
are just bunches of header files waiting to be #include'd later when you
are compiling an actual object (binary) file. The Filtering/ImageGrid
module is purely templated code (see that it has no "src/" directory), so
there is nothing to be done when ordinarily building it without Testing or
Examples enabled. Even running "make --always-make ITKImageGrid-all" to
force a rebuild of everything (equivalent to pretending that all of the
source files were modified) does nothing, as expected.

Conversely, the Filtering/LabelMap module does contain a "src/*.cxx" file,
so "make --always-make ITKLabelMap-all" will do some compilation work.
However, during this rebuild of ITKLabelMap-all, note that only the
non-templated class "itk::GeometryUtilities" is compiled for ITKLabelMap
target, but not any of the several dozen templated classes in this module
(again assuming Testing / Examples are disabled).

Furthermore, when you run "make ITKLabelMap-all" in a fully up-to-date
build, you should get:

> [ 14%] Built target itkNetlibSlatec
> [ 21%] Built target itksys
> [ 28%] Built target itkdouble-conversion
> [ 42%] Built target ITKVNLInstantiation
> [ 92%] Built target ITKCommon
> [100%] Built target ITKStatistics
> [100%] Built target ITKLabelMap
> [100%] Built target ITKLabelMap-all
>
This is to be expected, as the class being built in ITKLabelMap depends
upon classes in several other modules / targets, and they must be verified
as built up-to-date before the target ITKLabelMap-all (which trivially
depends on ITKLabelMap, if no Testing is built) can even be considered.
However, note that no other classes not in this dependency chain are
examined by Make.

-----

Also importantly, if you are using a multi-core computer (as nearly all
modern systems are), it's a good idea to be doing parallel builds. At the
simplest, this is using the "-j" option with Make, but see [1] for a good
overview.

Finally, if the slowness of Make is a problem, you may want to consider
Ninja [2] as an alternative build system, as it is generally much faster
(it spends much less time re-checking dependencies that are already built).
It it supported by the latest versions of CMake + ITK.

[1] http://www.kitware.com/blog/home/post/434
[2] https://github.com/martine/ninja

-----

I hope this helps you somewhat.

Enjoy,
Brian



On Fri, Nov 15, 2013 at 3:01 AM, Michka Popoff <michkapopoff at gmail.com>wrote:

> Hi
>
> I am still playing around with it, and I don't get it. I am able to
> recompile a single VTK module, or c++ files I made myself, but impossible
> to do anything with ITK.
> I tested under OS X and Fedora, to be sure it was not a platform dependent
> problem.
> Would it be possible to have a step by step tutorial ? It could also be
> added to the wiki for future users.
>
> Thanks for your help.
>
> Michka
>
>
> Le 3 nov. 2013 à 23:11, Matt McCormick a écrit :
>
> > Hi Michka,
> >
> > "make help" from the top of the build tree will list all build
> > targets.  This can be piped to grep to find the target of interest.
> > The "-all" targets will build both the library and the tests -- the
> > target with out the "-all" will just build the library and its
> > dependencies.  Another approach is to "cd" into the "test" directory
> > for the module in the build tree and run "make" from there.
> >
> > Thanks,
> > Matt
> >
> >
> > On Sat, Nov 2, 2013 at 4:47 PM, Michka Popoff <michkapopoff at gmail.com>
> wrote:
> >> Hi
> >>
> >> I successfully built ITK in a folder. I then made some modifications to
> a ITK module, in the source dir.
> >> I thought I could use the make command from the module's build folder
> (like I already did in VTK), to only recompile the current module.
> >>
> >> But it's only going through the files to see if everything is already
> built, and the it's telling me : Built target NameOfTheModule
> >>
> >> My question is : How do I recompile only one module / one file ?
> >>
> >> My question may seem obvious for c++/ITK developers, but as a Phytonist
> I can not figure it out ...
> >>
> >> Thanks in advance
> >>
> >> Michka
> >> _______________________________________________
> >> Community mailing list
> >> Community at itk.org
> >> http://public.kitware.com/cgi-bin/mailman/listinfo/community
>
> _______________________________________________
> Community mailing list
> Community at itk.org
> http://public.kitware.com/cgi-bin/mailman/listinfo/community
>



-- 
Brian Helba
Medical Imaging
Kitware, Inc.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20131115/0ef623e8/attachment.html>


More information about the Community mailing list