简体   繁体   中英

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".

在此处输入图片说明

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM