How does the C++ API work (and is there a mistake in the example?)

No, @KenArrari as per my understanding one of them will be needed at runtime. The .so file will be used by the application at runtime.