10

Per default, when compiling a Visual Studio project in release mode, the complete path to the pdb is put into the image file, e.g.:

c:\myprojects\demo\release\test.pdb

Using an undocumented linker switch (/pdbpath:none) one can force Visual Studio 2008 to reduce the full qualified name of the pdb, e.g:

test.pdb

I need to do the same with a project which is still built using VC6.

I tried the "/pdbpath:none" switch at the project settings level, but the linker complains about this unknown switch.

Does anyone knows a method (or a tool) to accomplish this either when linking a VC6 project or afterwards directly at the image level?

4
  • This switch is available (documented) starting with Visual Studio 2010
    – mox
    Commented Sep 29, 2011 at 11:27
  • This switch is also working with Visual Studio 2008.
    – mox
    Commented Feb 13, 2012 at 15:38
  • There is a tool called peupdate (website here) that will remove, strip or otherwise change this PDB string to any arbitrary value for an EXE or DLL. For your particular question, you would use the "-s" (strip) option to remove the path but leave the filename intact.
    – byteptr
    Commented Sep 10, 2016 at 0:24
  • See answers in Remove PDB references from released file
    – byteptr
    Commented Apr 7, 2021 at 18:44

2 Answers 2

3

Your best bet is to use pdbstr.exe from MS directly. It allows for direct extraction, update, and misc other functions directly, independent of compiler version (up to the last supported version, which I think is VS2013 right now). We use it to add SVN linkings directly to PDBs which we then store in local symbol stores using srctool.

3
  • Thanks! Interesting to see that this utility uses Alternate Data Stream (ADS)..."to insert the version control information into the "srcsrv" alternative stream of the target .pdb file".
    – mox
    Commented Jul 9, 2015 at 11:20
  • What would an example command line be to use pdbstr.exe? Even with the docs, I couldn't figure it out how to strip the path.
    – byteptr
    Commented Sep 10, 2016 at 0:32
  • @byteptr Sorry for the late reply. We use a Poweshell Script to build our new block in a temporary stream file ($streamContent), and then call the executable directly like this: . "$ToolPath"/pdbstr.exe -w -s:srcsrv "-p:$pdbFullName" "-i:$streamContent" This adds the given stream as a srcsrv stream to the pdb specified in $pdbFullName, which includes the path and all that.
    – Woody14619
    Commented May 16, 2017 at 20:52
3

For newer link.exe versions, the syntax changed.

The option you want is now /pdbaltpath:%_PDB%

It is documented on MSDN: https://msdn.microsoft.com/en-us/library/dd998269.aspx

%_PDB% expands to the file name of the actual .pdb file without any path information

For VC6, you might want to continue using the same compilers but a new version of link.exe.

The Windows Driver Kits also come with a tool named binplace.exe which can modify this information post-build.

4
  • This seems to be broken for static libraries. LNK4044: unrecognized option '/pdbaltpath:%_PDB%'; ignored
    – syplex
    Commented Mar 6, 2018 at 0:44
  • @syplex: What version of the linker are you using? And what do static libraries have to do with your problem?
    – Ben Voigt
    Commented Mar 6, 2018 at 2:14
  • Tried a few versions. Up to version 14.12.25835.0. Trying to figure out how to specify or alter the PDB path for a static library. The path is embedded into .lib like it is for DLLs/EXEs (albeit differently) but there is no way to modify it. I would expect something like PDBALTPATH to work for this, but haven't found anything.
    – syplex
    Commented Mar 6, 2018 at 2:22
  • Can the /PDBALTPATH be a relative path? e.g. ..\PDBs\mydll.pdb ? Commented Jan 15, 2020 at 15:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.