Edit me

Debugging Kratos using Visual Studio

As Kratos runs using Python scripts the debugging process using Visual Studio may be a bit different of what a normal user may be used to. You have two different known ways to be able to debug your code: Cross Debugging Python or debugging directly the C++ part. This page will focus in the second option. You can find a dedicated page of the wiki for cross debugging here.

Required software

  • Visual Studio 2015/2017 (see Windows Install) for debugging C++
  • Boost libraries in debug mode.

Preparing the environment

First make sure the code is configured and compiled in Debug or Fulldebug modes. We recommend you to have a separate build directories for Release and Debug.

Go to Kratos project, on the solution explorer, right click and select Properties. From here go to Debugging menu. you should see a window like this:

In this menu, you will need to change some options

  • Command: You should select python.exe you used to compile Kratos. Ex: C:\python36\python.exe
  • Command arguments: Name of the script of the case you want to run. Ex: MainKratos.py
  • Working directory: Path to the folder where the script above is located. Ex: C:\MyExamples\MyProblem.gid
  • Environment: You have to a add
    • PATH: so it also points to the Libs directory of Kratos where you have compiled the code. Ex: C:\Kratos_install\Libs
    • PYTHONPATH: it has to point to your kratos folder where the KratosMultiphysics directory is located. typically the same as above but without libs. Ex: C:\Kratos_install\Libs

Debugging

After that just right click in the Kratos -> Debug -> Start new debug instance:

Notice that you can put breakpoints and stop executions in all applications and components, not only in Kratos. Running from Kratos project just serves as an entry point in Visual Studio.

If you have any problem please feel free to open an issue in our project’s page: https://github.com/KratosMultiphysics/Kratos/issues