Thread overview
Windows + LDC/DMD installation nightmare when changing VS versions
Jun 12, 2020
Guillaume Piolat
Jun 12, 2020
mw
Jun 12, 2020
mw
Jun 12, 2020
Guillaume Piolat
Jun 12, 2020
Dukc
Jun 12, 2020
kinke
Jun 12, 2020
Guillaume Piolat
June 12, 2020
Originally I installed VisualD and LDC and DMD with the VisualD installer on top of VS2019 and life was good.

Then because VS2019 is very slow, I uninstalled VS2019 and installed VS2015 instead.
This broke both DMD+64-bit and LDC despite having LDC_VSDIR set at "invalid-path". Isn't it supposed to auto-detect? Well it wasn't anymore and LINK.EXE would not get found.

I then reinstalled stuff with the VisualD installer, which fixed DMD + 64-bit (Linking stage was never finishing) but not LDC + 32-bit.


Now:
- With DMD + 64-bit it works.
- With DMD + 32-bit it works.
- With LDC + 64-bit it works.
- With LDC + 32-bit it still fail with:

  libcmt.lib(chkstk.obj) : fatal error LNK1112: module machine type 'X86' conflicts with target machine type 'x64'
  Error: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\link.exe failed with status: 1112
  ldc2 failed with exit code 1.
  error: Command 'dub build --build=debug --arch=x86_64 --compiler=ldc2 --config=VST-FULL' returned 2


Any idea what could be causing this?

Please help. This was a living nightmare. I just want a working setup...
June 12, 2020
On Friday, 12 June 2020 at 15:21:12 UTC, Guillaume Piolat wrote:
> 
> - With LDC + 32-bit it still fail with:
>
>   libcmt.lib(chkstk.obj) : fatal error LNK1112: module machine type 'X86' conflicts with target machine type 'x64'
>   Error: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\link.exe failed with status: 1112
>   ldc2 failed with exit code 1.
>   error: Command 'dub build --build=debug --arch=x86_64

--arch=x86_64 ?

check where this config is set? you said it’s for 32 bit


> --compiler=ldc2 --config=VST-FULL' returned 2
>



June 12, 2020
On Friday, 12 June 2020 at 16:16:18 UTC, mw wrote:
> On Friday, 12 June 2020 at 15:21:12 UTC, Guillaume Piolat wrote:
>> 
>> - With LDC + 32-bit it still fail with:
>>
>>   libcmt.lib(chkstk.obj) : fatal error LNK1112: module machine type 'X86' conflicts with target machine type 'x64'
>>   Error: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\link.exe failed with status: 1112
>>   ldc2 failed with exit code 1.
>>   error: Command 'dub build --build=debug --arch=x86_64
>
> --arch=x86_64 ?
>
> check where this config is set? you said it’s for 32 bit
>
>
>> --compiler=ldc2 --config=VST-FULL' returned 2


> - With DMD + 32-bit it works.

Find the corresponding DMD working command config, and set it to ldc2 accordingly.
June 12, 2020
On Friday, 12 June 2020 at 15:21:12 UTC, Guillaume Piolat wrote:
> Any idea what could be causing this?
>
> Please help. This was a living nightmare. I just want a working setup...

I don't know if this is any help, as I don't use Visual Studio myself, but:

You're trying to build for a 32-bit architechture, but the DUB receives `--arch=x86_64`. It should be receiving `--arch=x86`. It's likely that due to this it builds a 64-bit binary and then fails to link into something that was correctly built as 32-bit.
June 12, 2020
On Friday, 12 June 2020 at 16:16:18 UTC, mw wrote:
>
> --arch=x86_64 ?
>
> check where this config is set? you said it’s for 32 bit
>
>

Indeed it's the other way around, it's with -a x86_64


June 12, 2020
On Friday, 12 June 2020 at 15:21:12 UTC, Guillaume Piolat wrote:
> Any idea what could be causing this?

Mentioning at least the used LDC version would be helpful; especially since the MSVC detection was completely overhauled with the v1.22 betas (and I think the previous non-existing-LDC_VSDIR hack wouldn't work anymore).

LDC doesn't need a reinstall when tampering the VS installations (there's no setup process, MSVC auto-detection runs each time). - Assuming you are using an LDC version < 1.22, you can manually check the auto-detection result by invoking `bin\msvcEnv.bat <x64|x86>` (e.g., by checking the env variables afterwards via `set`). Some leftovers from uninstalled VS installations might be problematic, but probably hardly the reason for a 32-bit libcmt.lib to be linked with a 64-bit target.

But I'd start first with checking whether LDC/dub works in a naked command prompt, to rule out that VisualD is interfering. [And adding -v to the LDC commandline is useful for debugging linking problems.]
June 12, 2020
On Friday, 12 June 2020 at 19:21:46 UTC, kinke wrote:
> On Friday, 12 June 2020 at 15:21:12 UTC, Guillaume Piolat wrote:
>> Any idea what could be causing this?
>
> Mentioning at least the used LDC version would be helpful; especially since the MSVC detection was completely overhauled with the v1.22 betas (and I think the previous non-existing-LDC_VSDIR hack wouldn't work anymore).
>
> LDC doesn't need a reinstall when tampering the VS installations (there's no setup process, MSVC auto-detection runs each time). - Assuming you are using an LDC version < 1.22, you can manually check the auto-detection result by invoking `bin\msvcEnv.bat <x64|x86>` (e.g., by checking the env variables afterwards via `set`). Some leftovers from uninstalled VS installations might be problematic, but probably hardly the reason for a 32-bit libcmt.lib to be linked with a 64-bit target.
>
> But I'd start first with checking whether LDC/dub works in a naked command prompt, to rule out that VisualD is interfering. [And adding -v to the LDC commandline is useful for debugging linking problems.]

Thanks a lot. I was trying with LDC 1.17.0 and LDC 1.20.1
64-bit linking works within a VSvars shell.
It also seems I have disc-related problems, so a faulty VS installation might be at fault.
Anyway, thanks everyone for the help. I'm doing a dskchk while installing on another laptop. ^^