1

I got some compiled C++ libraries (.lib, not compiled by myself) which I link in my own C++ project. I also got the source code.

Is it possible while debugging to step into functions from those libraries using the source code? How can I tell the Visual Studio debugger to use those source code files?

I guess that .lib files would need some kind of debugging information - can I find out if they got those?

ZoolWay
  • 5,411
  • 6
  • 42
  • 76
  • [Pretty close](http://stackoverflow.com/questions/4316801/pointing-visual-studio-2008-to-the-source-code-of-a-third-party-dll-for-debuggin), but maybe I'll find a better one. – Baum mit Augen Nov 15 '16 at 11:01
  • [Also very close](http://stackoverflow.com/questions/2620279/visual-studio-attach-source-code-to-reference), but wrong language. Can you please check if that works for C++ too? – Baum mit Augen Nov 15 '16 at 11:03

1 Answers1

2

Microsoft compilers store debugging information in separate .pdb files. When VS loads a library (say myLib ) used by an executable ( either by attaching to a running instance, or by starting it directly under debugger), it also searches for myLib.pdb. If it finds it, when you try to step in such a function, it will first ask you the location of the source corresponding to it. If it is correctly provided, you will be able to debug it.

Without .pdb files, I do not know any way to debug the external library at source code level.

Also, if there are no .pdb files, but you do have the source code for the external library, would it be possible for you to re-build it with debugging symbols (.pdb files ) ?

  • Actually I am currently trying to rebuild them to get matching PDB files. But takes some experimentation as I do not know which options for used for the compiled binaries I already got. Will come back once I succeeded. – ZoolWay Nov 16 '16 at 15:15
  • @ZoolWay, if George Spatacean's reply is helpful for you, if possible, please mark it as the answer, so it could help other community members who met the same issue as yours:) – Jack Zhai Nov 21 '16 at 08:31
  • Ok, I managed to rebuild it (WebRTC native is quite complex). So I got the `lib` and `pdb` files. Still it does not step into the source even if I use *Step into specific*. Guess this does not work with the mixed debugger - this is managed and unmanaged code mixed. – ZoolWay Nov 24 '16 at 15:43