www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - dmd64 on Windows: how?

reply Ivan Kazmenko <gassa mail.ru> writes:
Hi,

How should I set up DMD to be able to `dmd -m64` on Windows 
nowadays?

I usually download the 7z, but it broke when I replaced my Visual 
Studio with 2017 edition.

Now, I tried the current 2.081.1 .exe installer.  It didn't 
propose any additional 64-bit related options.  After the 
installation, `dmd -m64` complains that the linker could not find 
`libcmt.lib`.

The previous time I tried finding the right `libcmt` and treating 
the subsequent errors, I failed to locate all the correct 
libraries in Microsoft's Visual Studio and SDKs.  This time, I'd 
rather follow some up-to-date guide than waste the time again.

So, what's the most current guide to make 64-bit linking work on 
Windows?  I'm fine with having to install more LLVM or MinGW or 
Microsoft stuff, I just don't seem to know what I need.

Ivan Kazmenko.
Aug 10 2018
next sibling parent Laurent =?UTF-8?B?VHLDqWd1aWVy?= <laurent.treguier.sink gmail.com> writes:
On Friday, 10 August 2018 at 12:15:55 UTC, Ivan Kazmenko wrote:
 Hi,

 How should I set up DMD to be able to `dmd -m64` on Windows 
 nowadays?

 I usually download the 7z, but it broke when I replaced my 
 Visual Studio with 2017 edition.
If you were using another Visual Studio version, since VS 2017 operates differently, in a more modular fashion, you'll have to use the Visual Studio 2017 installer to modify your installation and add the correct Windows SDKs. I'm not on my machine and haven't done this in quite some time, so I don't remember which package exactly is needed... But if you have already done this however, then I don't know what the problem could be.
Aug 10 2018
prev sibling next sibling parent Kagamin <spam here.lot> writes:
The dmd installer should normally deal with it, maybe it doesn't 
support VS2017 yet or you didn't install VC++. Try to uninstall 
dmd, delete its configuration files and install again.
Aug 10 2018
prev sibling parent reply Laurent =?UTF-8?B?VHLDqWd1aWVy?= <laurent.treguier.sink gmail.com> writes:
On Friday, 10 August 2018 at 12:15:55 UTC, Ivan Kazmenko wrote:
 Hi,

 How should I set up DMD to be able to `dmd -m64` on Windows 
 nowadays?

 I usually download the 7z, but it broke when I replaced my 
 Visual Studio with 2017 edition.

 Now, I tried the current 2.081.1 .exe installer.  It didn't 
 propose any additional 64-bit related options.  After the 
 installation, `dmd -m64` complains that the linker could not 
 find `libcmt.lib`.

 The previous time I tried finding the right `libcmt` and 
 treating the subsequent errors, I failed to locate all the 
 correct libraries in Microsoft's Visual Studio and SDKs.  This 
 time, I'd rather follow some up-to-date guide than waste the 
 time again.

 So, what's the most current guide to make 64-bit linking work 
 on Windows?  I'm fine with having to install more LLVM or MinGW 
 or Microsoft stuff, I just don't seem to know what I need.

 Ivan Kazmenko.
Did you have a look at the wiki ? It looks like the image shows what needs to be installed: https://wiki.dlang.org/Installing_DMD#Installing_the_Microsoft_toolchain
Aug 10 2018
parent reply Ivan Kazmenko <gassa mail.ru> writes:
Well, I tried all your suggestions.
(Actually re-tried a few times.)
Thanks, Laurent and Kagamin!

On Friday, 10 August 2018 at 14:47:04 UTC, Laurent Tréguier wrote:
 Did you have a look at the wiki ? It looks like the image shows 
 what needs to be installed:
 https://wiki.dlang.org/Installing_DMD#Installing_the_Microsoft_toolchain
This was most close to solving my problem. Thanks! I've installed the components shown in wiki image: v141 tools and the SDKs. The sc.ini information in the wiki looks outdated. At least the sc.ini from the .7z archive is much cleaner than it used to be. The whole 64-bit section looks like this: ~~~~~ [Environment64] LIB=% P%\..\lib64 ; needed to avoid COMDAT folding (bugzilla 10664) DFLAGS=%DFLAGS% -L/OPT:NOICF ~~~~~ So I proceeded with the wiki instructions: to find and run a 64-bit Visual Studio command prompt, to ask the environment variables from there. And Visual Studio 2017 brings new tricky paths to handle. Here is how my sc.ini 64-bit section looks now, when everything seems to work: ~~~~~ [Environment64] LIB=% P%\..\lib64 ; needed to avoid COMDAT folding (bugzilla 10664) DFLAGS=%DFLAGS% -L/OPT:NOICF ; here are the actual paths VCINSTALLDIR=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\ WindowsSdkDir=C:\Program Files (x86)\Windows Kits\10\ UniversalCRTSdkDir=C:\Program Files (x86)\Windows Kits\10\ UCRTVersion=10.0.17134.0 ; here is the actual version LINKCMD=%VCINSTALLDIR%\Tools\MSVC\14.14.26428\bin\HostX64\x64\link.exe ; needed with /DEBUG to find mspdb*.dll (only for VS2012 or later) PATH=%PATH%;%VCINSTALLDIR%\bin\HostX64\x64 ~~~~~ Specifically, LINKCMD part deviates from the instructions. The linker is now buried deeper into \Tools\MSVC\14.14.26428\bin\HostX64\x64\. Yep, that contains a version number too, which may change with each update. Meanwhile, the tutorial suggests just the following: LINKCMD=%VCINSTALLDIR%\bin\x86_amd64\link.exe Anyway, now 64-bit linking seems to be working, so I'll stop digging. Ivan Kazmenko.
Aug 11 2018
parent reply Mike Parker <aldacron gmail.com> writes:
On Saturday, 11 August 2018 at 19:50:30 UTC, Ivan Kazmenko wrote:
n
 This was most close to solving my problem.  Thanks!

 I've installed the components shown in wiki image: v141 tools 
 and the SDKs.
VS 2017 Community includes everything you need. There's no reason to install the SDK separately. If it's installed first, the DMD installer will find it. The latest version will install the MinGW system libs and the lld linker if no VS installation is found. And for the past few versions, when you run dmd it will look for the VS installation as needed. So it should work out of the box without the need for the separate SDK or mucking about with the paths in sc.ini. Is your VS 2017 the Community edition?
Aug 11 2018
parent Ivan Kazmenko <gassa mail.ru> writes:
On Sunday, 12 August 2018 at 03:49:04 UTC, Mike Parker wrote:
 On Saturday, 11 August 2018 at 19:50:30 UTC, Ivan Kazmenko 
 wrote:
 I've installed the components shown in wiki image: v141 tools 
 and the SDKs.
VS 2017 Community includes everything you need. There's no reason to install the SDK separately. If it's installed first, the DMD installer will find it. The latest version will install the MinGW system libs and the lld linker if no VS installation is found. And for the past few versions, when you run dmd it will look for the VS installation as needed. So it should work out of the box without the need for the separate SDK or mucking about with the paths in sc.ini. Is your VS 2017 the Community edition?
Yeah, I have VS 2017 Community Edition, and I was struggling trying to make 64-bit linking work, both with .7z archive and with .exe installer. The .exe installer dmd-2.081.1.exe I've just tried again. With default settings, it just installs into C:\D\ . Its sc.ini is almost empty, no sign of Visual Studio environment variables or paths. Then I run cmd.exe: ~~~~~ Microsoft Windows [Version 6.1.7601] Copyright (c) 2009 Microsoft Corporation. All rights reserved. C:\D>dmd2vars64.bat Setting up 64-bit environment for using DMD 2 from C:\D\dmd2\windows\bin. dmd must still be called with -m64 in order to generate 64-bit code. This command prompt adds the path of extra 64-bit DLLs so generated programs which use the extra DLLs (notably libcurl) can be executed. C:\D>echo void main () {} > a.d C:\D>dmd -m64 a.d C:\D\dmd2\windows\bin\lld-link.exe: error: could not open libcmt.lib: no such fi le or directory Error: linker exited with status 1 ~~~~~ My Windows version is Windows Server 2008 R2. Microsoft Visual Studio Community 2017, version 15.7.6. At C:\Program Files (x86), there are: Microsoft Visual Studio [ 2754M ] Microsoft Visual Studio 12.0 [ 50M ] Microsoft Visual Studio 14.0 [ 954M ] The latter two contain some remains of the previous installations, so that may be the issue with detecting the current Visual Studio version. Ivan Kazmenko.
Aug 12 2018