It is possible to use the functionality of Cadabra directly from C++ code, without dealing with the Python layer on top of it, and without using the notebook interface. The library is called cadabra2++ and building and installation instructions are provided in the project's README. Here we describe how to use this library.
The output of this program is 2 A B. Most of the above should be fairly easy to understand for anyone who has worked with the Python interface to Cadabra before. Note how properties are attached to objects using the inject_property function call. This takes the kernel as argument, as well as a textual expression of what you would use in the Python interface. Algorithms are C++ objects, which you need to instantiate, and then run explicitly by calling the apply_generic function. As in the Python version, algorithms act in-place (mostly), and the ex expression above thus changes as the code progresses. Finally, the expression is printed by using the pprint function. This is necessary because printing requires information stored in the Cadabra kernel.