ArKi
ArKi

Reputation: 701

How can I set a breakpoint in a C++ static library from my C# project?

I have a static library written in C++, which can be downloaded in binary or compiled from source here. In that static library, I would like to set a breakpoint at a function call. I have created a wrapper C++ DLL to that static library, and a C# unit test project that calls functions in that C++ DLL. However, when I try to debug the static library, the functions are greyed out (see below), and I get a message that says "Source Not Available".

enter image description here

How would it be possible to step into the source code and set a breakpoint? I tried using Debug > New Breakpoint > Function Breakpoint, but if I type in a function like module_runtime_path, it doesn't break at all. Unfortunately, the current source doesn't allow for building from Visual Studio (it can only be built from Ninja). If I build using Ninja, I've also tried adding all sorts of PDB locations but to no avail.

Is there any way for me to set a breakpoint in the static library?

Upvotes: 1

Views: 1424

Answers (1)

ArKi
ArKi

Reputation: 701

I can't pinpoint the exact solution, but I ended up building from source and setting in my C++ DLL project, in Properties > Configuration Properties > Linker > Debugging, I set Generate Debug Info=Optimize for debugging (/DEBUG). After that, I was able to step into the static library.

Upvotes: 0

Related Questions