I am using a CMAKE command to install PDB files to enable debugging in a developer distribution of my C++ application. The command is as below:
Turning my comments into an answer; based largely on information from this question and the links in there.
PDB files store absolute path names to the source files. When not using a symbol server, the only way to ensure some degree of source code relocatability is to use the
The idea is to use
subst to create a drive-letter name (e.g.
N:\) for the root of the source tree. Then do your builds from this drive, so that absolute paths starting with
N:\ get embedded into the PDBs. When you later need to debug the executable on a different machine, use
subst on that machine to get the same absolute paths to the sources. This will enable the PDBs to find the source files.
For example, if you have a file
C:\MySources\main.cpp, do the following:
subst N: C:\MySources N: run your build
Later, let's say you need to debug on a machine where the same file is stored in
D:\Devel\Other\main.cpp. Simply do
subst N: D:\Devel\Other and then work from the
N: drive there as well.