bombela/backward-cpp

using "backward" in Windows OS

kondrahin241996 opened this issue · 4 comments

Hello. I have a small issue with connecting the header library "backward".
I have successfully connected "backward under Linux. I also connected the elfutils library. I built it using the make utility. I'm getting a trace.

I would really like to use "backward" to output stack traces under Windows OS as well.
At the moment, I have added a file.hpp as src. Before the main function, I wrote the following code:

#include "backward.hpp"
#define BACKWARD_HAS_DW 1
namespace backward {
backward::SignalHandling sh;
} // namespace backward

I am building and compiling in the "Debug" mode. But when the program starts, the trace is not displayed.
Can you help me with connecting this header library to the Visual Studio environment in Windows?
Which connection algorithm should I reproduce?

Note that #define BACKWARD_HAS_DW 1 must be defined before #include "backward.hpp". And you would then also need to link with the dw library. But this is specific to UNIX, and doesn't apply to MS Windows.

For MS Windows see for reference https://github.com/bombela/backward-cpp/blob/master/BackwardConfig.cmake#L204 and https://github.com/bombela/backward-cpp/blob/master/backward.hpp#L361. By default it should just work.

backward::SignalHandling sh; will only print a trace when a signal is raise (including on un-handled exception). You can read the documentation (https://github.com/bombela/backward-cpp#stacktrace) for printing traces on demand.

Did I understand correctly that the link #L204 to generate my project via cmake?
If I don't use cmake and just attach the file .hpp, then should everything work?

Thank you very much for the quick response! You've helped me a lot.