I built a dynamic library using C++ to connect through GDNative with my Godot game.

The native library compiles without any error and the game runs properly except at times when the game crashes. The Godot debugger provides no information about the crash (no error or warning), just reporting that the debugging process stopped.

Now, it could be GDScript that caused the crash, but we were likely to get information about any runtime error if it was GDScript, right? Thus, I assume that it's the native library that is causing the runtime issue.

So, how can I ensure that the native library isn't having runtime issues? Yes, I can test it separately in a C++ debugger but the problem is that it's totally dependent on the game and I can't reproduce the scenario that causes the crash when used with Godot.

Is there any way to make Godot capture the standard output/error streams of the library and log them down? C++ usually reports issues about any runtime crash, such as "segmentation fault".

Yes, I can test it separately in a C++ debugger but the problem is that it's totally dependent on the game and I can't reproduce the scenario that causes the crash when used with Godot.

Can't you use a C++ debugger and run the project directly using command line arguments?

Also, I think printf()s executed inside the library would display in the terminal/command window. Make sure to start Godot from a terminal/command prompt so that you can see its output. It may not be present in the editor's Output panel which only features some Godot prints.

a year later