There are many questions on the Internet for "missing mspdb140.dll", and other similar questions about missing "mspdb*" DLLs. There are a few different solutions posted about it, including:
- reinstall Visual Studio
- Remove mspdb140.dll, it should be included with the PATH variable
- Add mspdb140.dll (and other files) to
<msvc-install-dir>\<subpath>
In my case, I have used the build tools for msvc 2019 installer in a docker container, and then installed both build tools for msvc 2017 and 2019. If I then go to C:\BuildTools\VC\Tools\MSVC\14.16.27023\bin\HostX64
, there are two folders: x64
and x86
. If I write the powershell command ls -Recurse -Filter "*mspdb*"
, I get the following output:
Directory: C:\BuildTools\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64
mspdb140.dll
mspdbcmf.exe
mspdbcore.dll
mspdbsrv.exe
mspdbst.dll
Directory: C:\BuildTools\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64\1033
mspdbcmfui.dll
There is none of these files in the HostX64\x86
directory though. If I build with x64 as target everything goes fine, but with x86 as target, both the release and debug build gets error. The release build has:
ERROR: C:\BuildTools\VC\Tools\MSVC\14.16.27023\bin\HostX64\x86\cl.exe
...
c1xx: fatal error C1356: unable to find mspdbcore.dll
and the debug build has:
ERROR: C:\BuildTools\VC\Tools\MSVC\14.16.27023\bin\HostX64\x86\cl.exe
...
c1xx: fatal error C1356: unable to find mspdb140.dll
These builds are using Qt and Qbs, and Qbs uses vcvarsall.bat to find the environment variables needed. There is a bug in Qbs when having multiple installed msvc toolchains, which makes Qbs always choose the newest one. To work around this, I manually move vcvarsall.bat and replace it with this in each build job:
call %~dp0vcvarsall_real.bat %1 store 10.0.17134.0 -vcvars_ver=14.16.27023 || exit /b 1
This forces vcvarsall to choose the toolchain 14.16.27023 that I want.
I managed to fix both of the compilation errors by simply copying the DLL and EXE files that exists for the x64 target, except mspdbcmfui.dll
. There is no reason for not copying that last DLL, as I am just experimenting. Even though the program compiles, I don't really know what I'm doing, where these files are used, or why they are missing for some targets! It would feel better to not have to manually copy files in my build environment.
I also checked my local installation of Visual Studio 2017 Professional, and then I have the same name of the files for HostX64\x64, but for HostX64\x86 I get this output:
C:\Program Files (x86)\Microsoft Visual Studio\2017\WDProfesional\VC\Tools\MSVC\14.16.27023\bin\Hostx64\x86
...
mspdb140.dll
mspdbcore.dll
Only two of the DLLs!
In the docker image, I also have the build tools for MSVC 2019, and there all of the host and target combinations have all of the DLLs and EXEs.
To summarize:
- Why are there missing DLLs in some cases
- What is the correct way of fixing this?
- How does Visual Studio compile differ from using vcvarsall.bat and external tools, as it is clearly able to compile without copying DLLs/EXEs!