Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using "backward" in Windows OS #320

Closed
kondrahin241996 opened this issue Dec 1, 2023 · 4 comments
Closed

using "backward" in Windows OS #320

kondrahin241996 opened this issue Dec 1, 2023 · 4 comments

Comments

@kondrahin241996
Copy link

kondrahin241996 commented Dec 1, 2023

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?

@bombela
Copy link
Owner

bombela commented Dec 1, 2023

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.

@kondrahin241996
Copy link
Author

kondrahin241996 commented Dec 2, 2023

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?

@bombela
Copy link
Owner

bombela commented Dec 2, 2023 via email

@kondrahin241996
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants