Comment #0 by thomas.hedstrom — 2017-05-08T18:05:47Z
Created attachment 1646
Not working project
Building console app "Hello World" generated from D project templates for target LDC x64 (release or debug) results in linker error:
"LINK : fatal error LNK1171: unable to load mspdb140.dll (error code: 126)
Error: P:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\bin\HostX86\x64\link.exe failed with status: 1171"
Tested LDC 1.2.0 and 1.3.0-beta1
VS2017 Community
VisualD-v0.44.2
DMD x86,x64 and LDC x86 all compiles.
A minimal patch of the build .cmd file indicates that the variable "VSINSTALLDIR" is the cause. Changing "set VSINSTALLDIR=P:\Program Files (x86)\Microsoft Visual Studio\2017\Community\"
to empty (or removing it) make it work.
"set VSINSTALLDIR="
(The original path exists and seems correct though)
Comment #1 by kinke — 2017-05-08T18:54:24Z
The problem is with PATH. The mspdb* DLLs seem to be available for the 2 native linkers (x86 => x86, x64 => x64) only, so for 64-bit targets, it should be `...\bin\HostX64\x64` (the linker being able to use > 3 GB memory being a nice side effect). The WinSDK dir for PATH should most likely also be x64 instead of the current x86 one.
[By clearing VSINSTALLDIR, LDC takes care of setting up the environment and that's why it works (1.3 at least, 1.2 doesn't support VS 2017).]
Comment #2 by r.sagitario — 2017-05-09T06:45:19Z
kinke's right, the DLL is missing for the cross compilation x86 <-> x64. Visual D uses the x86 folders in case you are working on a 32-bit host OS.
There are two workarounds:
1. if you are on 64-bit OS, you can just replace the LDC x64 executable search path
$(VCTOOLSINSTALLDIR)bin\HostX86\x64
with
$(VCTOOLSINSTALLDIR)bin\HostX64\x64
2. add another folder to the LDC x64 executable search path:
$(VSINSTALLDIR)Common7\IDE
Visual D doesn't use LDC's automatic detection because it doesn't allow using different versions of VS.
Comment #3 by kinke — 2017-06-10T10:35:41Z
> Visual D doesn't use LDC's automatic detection because it doesn't allow
> using different versions of VS.
It is possible - via env variable `LDC_VSDIR`. For LDC 1.0.0 compatibility, it'd have to end with a backslash, e.g., `LDC_VSDIR=C:\Program Files (x86)\Microsoft Visual Studio 12.0\`.