How to Compile Kratos in Debug mode

From KratosWiki
Revision as of 08:49, 25 October 2016 by Vmataix (Talk | contribs)
Jump to: navigation, search

In order to compile Kratos in Debug mode, you have to edit your compilation script '' by changing the line begining with '-DCMAKE_BUILD_TYPE':

Instead of -DCMAKE_BUILD_TYPE=Release, type:

   -DCMAKE_BUILD_TYPE=Debug     \

If your goal is to compile Kratos in Release mode, but containing all the source code information, instead of the previous option type:

   -DCMAKE_BUILD_TYPE=RelWithDebInfo     \

This Debug version of the code contains the majority of the code in its pure Debug version, but some parts would be so slow that they are not actually compiled Debug (UBLAS objects). If you want the 100% Debug version of Kratos, including UBLAS, set the following variables, too:


but keep in mind that these options are not necessary in general, and make Kratos be really slow!

Exceptionally, in Linux you can also add the compilation flag -D_GLIBCXX_DEBUG. This flag will define the variable _GLIBCXX_DEBUG, which activates many verifications in the STL libraries. Run the code normally and it will crash when it finds some error. This also makes your code very slow. To find out the call stack, it is recommended to use a debugger, because the code crashes and tells you the type of error, but not the location in the code.

Keeping both a Release and a Debug version of Kratos at the same time:

You will notice that switching from one compilation to another takes long, since all the source code is completely re-compiled when you change the compilation mode. A solution to this problem is to compile the code in different folders. This can be done by creating folders similar to the cmake_build folder. For instance, you can create an extra folder called 'cmake_build_debug' by doing this from the main kratos folder:

   mkdir cmake_build_debug
   cp cmake_build/ cmake_build_debug/

Then, edit '' by setting the Debug mode with:


Now you can compile the debug version of Kratos by doing:

   cd cmake_build_debug

And you can compile (if you did not yet) the release version of Kratos by doing:

   cd ../cmake_build

Now, both versions coexist.

When you run a Python script that calls the Kratos library, it will call the last one you compiled.

Personal tools