www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - How to use LLD linker?

reply Suliman <evermind live.ru> writes:
Correct me if I am wrong, but I have read news that dmd now can 
be used without C++ Build Tools.

I trying to build simple project. And getting Error:

Warning: no Visual C++ installation detected
OPTLINK (R) for Win32  Release 8.00.17
Copyright (C) Digital Mars 1989-2013  All rights reserved.
http://www.digitalmars.com/ctg/optlink.html
OPTLINK : Error 8: Illegal Filename
...

Error: C:\D\dmd2\windows\bin\link.exe failed with status: 1
ldc2 failed with exit code 1.

Same with dmd.

How to use LLD linker?
Jun 30 2018
parent reply SrMordred <patric.dexheimer gmail.com> writes:
On Saturday, 30 June 2018 at 10:48:49 UTC, Suliman wrote:
 Correct me if I am wrong, but I have read news that dmd now can 
 be used without C++ Build Tools.

 I trying to build simple project. And getting Error:

 Warning: no Visual C++ installation detected
 OPTLINK (R) for Win32  Release 8.00.17
 Copyright (C) Digital Mars 1989-2013  All rights reserved.
 http://www.digitalmars.com/ctg/optlink.html
 OPTLINK : Error 8: Illegal Filename
 ...

 Error: C:\D\dmd2\windows\bin\link.exe failed with status: 1
 ldc2 failed with exit code 1.

 Same with dmd.

 How to use LLD linker?
Well I just installed the VS 2017 to try the ldc and get (maybe) the same error. dub run --config=application --arch=x86_64 --build=debug --compiler=ldc2 Performing "debug" build using ldc2 for x86_64. lib ~master: building configuration "application"... OPTLINK (R) for Win32 Release 8.00.17 Copyright (C) Digital Mars 1989-2013 All rights reserved. http://www.digitalmars.com/ctg/optlink.html OPTLINK : Error 8: Illegal Filename /NOLOGO /DEBUG /OPT:REF /OPT:ICF /DEFAULTLIB:libcmt /DEFAULTLIB:libvcruntime "/OUT:.dub\build\application-debug-windows-x86_64-ldc_2081-FC0CCB721F0C7E0D58B93 B1E50E3401\lib.exe" ".dub\obj\lib.obj" "d:\ldc2\lib\ldc_rt.builtins.lib" /LIBPATH:d:/ldc2/bin/../lib phobos2-ldc.lib druntime-ldc.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib ^ Error: d:\D\dmd2\windows\bin\link.exe failed with status: 1 ldc2 failed with exit code 1.
Jul 05 2018
next sibling parent Suliman <evermind live.ru> writes:
 Well I just installed the VS 2017 to try the ldc and get 
 (maybe) the same error.

 dub run --config=application --arch=x86_64 --build=debug 
 --compiler=ldc2
 Performing "debug" build using ldc2 for x86_64.
 lib ~master: building configuration "application"...
 OPTLINK (R) for Win32  Release 8.00.17
 Copyright (C) Digital Mars 1989-2013  All rights reserved.
 http://www.digitalmars.com/ctg/optlink.html
 OPTLINK : Error 8: Illegal Filename
 /NOLOGO /DEBUG /OPT:REF /OPT:ICF /DEFAULTLIB:libcmt 
 /DEFAULTLIB:libvcruntime 
 "/OUT:.dub\build\application-debug-windows-x86_64-ldc_2081-FC0CCB721F0C7E0D58B93
B1E50E3401\lib.exe" ".dub\obj\lib.obj" "d:\ldc2\lib\ldc_rt.builtins.lib"
/LIBPATH:d:/ldc2/bin/../lib phobos2-ldc.lib druntime-ldc.lib kernel32.lib
user32.lib gdi32.lib
 winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib 
 comdlg32.lib advapi32.lib

 
             ^
 Error: d:\D\dmd2\windows\bin\link.exe failed with status: 1
 ldc2 failed with exit code 1.
Could you please try: dub build --force And write here if it's help
Jul 06 2018
prev sibling next sibling parent reply Rainer Schuetze <r.sagitario gmx.de> writes:
On 06/07/2018 05:48, SrMordred wrote:
 On Saturday, 30 June 2018 at 10:48:49 UTC, Suliman wrote:
 Correct me if I am wrong, but I have read news that dmd now can be 
 used without C++ Build Tools.

 I trying to build simple project. And getting Error:

 Warning: no Visual C++ installation detected
 OPTLINK (R) for Win32  Release 8.00.17
 Copyright (C) Digital Mars 1989-2013  All rights reserved.
 http://www.digitalmars.com/ctg/optlink.html
 OPTLINK : Error 8: Illegal Filename
 ...

 Error: C:\D\dmd2\windows\bin\link.exe failed with status: 1
 ldc2 failed with exit code 1.

 Same with dmd.

 How to use LLD linker?
Well I just installed the VS 2017 to try the ldc and get (maybe) the same error. dub run --config=application --arch=x86_64 --build=debug --compiler=ldc2 Performing "debug" build using ldc2 for x86_64. lib ~master: building configuration "application"... OPTLINK (R) for Win32  Release 8.00.17 Copyright (C) Digital Mars 1989-2013  All rights reserved. http://www.digitalmars.com/ctg/optlink.html OPTLINK : Error 8: Illegal Filename /NOLOGO /DEBUG /OPT:REF /OPT:ICF /DEFAULTLIB:libcmt /DEFAULTLIB:libvcruntime "/OUT:.dub\build\application-debug-windows-x86_64-ldc_2081-FC0CCB721F0C7E0D58B93 B1E50E3401\lib.exe" ".dub\obj\lib.obj" "d:\ldc2\lib\ldc_rt.builtins.lib" /LIBPATH:d:/ldc2/bin/../lib phobos2-ldc.lib druntime-ldc.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib             ^ Error: d:\D\dmd2\windows\bin\link.exe failed with status: 1 ldc2 failed with exit code 1.
The problem is that the Digital Mars linker is called but the Microsoft linker is run, because they share the same name link.exe. For dmd/x64/32mscoff or LDC in general the latter is expected to be used. Usually dmd and ldc know how to find the appropriate one, but dub might just expect it to be found through the PATH environment variable. So, try to set your PATH so that the MS linker is found first.
Jul 06 2018
parent reply SrMordred <patric.dexheimer gmail.com> writes:
On Friday, 6 July 2018 at 10:55:47 UTC, Rainer Schuetze wrote:
 On 06/07/2018 05:48, SrMordred wrote:
 [...]
The problem is that the Digital Mars linker is called but the Microsoft linker is run, because they share the same name link.exe. For dmd/x64/32mscoff or LDC in general the latter is expected to be used. Usually dmd and ldc know how to find the appropriate one, but dub might just expect it to be found through the PATH environment variable. So, try to set your PATH so that the MS linker is found first.
Yep, this is the way, but i could make it work yet. The PATH works, but i get errors relate to libs, even running vcvarsall.bat. Thats bizarre since its a fresh intallation of VS. It used to work, not sure what happened. Anyway i'll give up by now and try another time. I thought that LDC removed this VS dependecy.
Jul 06 2018
parent 0xEAB <desisma heidel.beer> writes:
On Friday, 6 July 2018 at 17:32:09 UTC, SrMordred wrote:
 On Friday, 6 July 2018 at 10:55:47 UTC, Rainer Schuetze wrote:
 On 06/07/2018 05:48, SrMordred wrote:
 [...]
The problem is that the Digital Mars linker is called but the Microsoft linker is run, because they share the same name link.exe. For dmd/x64/32mscoff or LDC in general the latter is expected to be used. Usually dmd and ldc know how to find the appropriate one, but dub might just expect it to be found through the PATH environment variable. So, try to set your PATH so that the MS linker is found first.
Yep, this is the way, but i could make it work yet. The PATH works, but i get errors relate to libs, even running vcvarsall.bat. Thats bizarre since its a fresh intallation of VS. It used to work, not sure what happened. Anyway i'll give up by now and try another time. I thought that LDC removed this VS dependecy.
The latest stable release didn't, at least. Which means, if it cannot locate the Windows SDK, it will call `link.exe` and hope to execute something useful, which - as already stated before - isn't the case and usually leads to OptLink.
Jul 06 2018
prev sibling parent reply 0xEAB <desisma heidel.beer> writes:
On Friday, 6 July 2018 at 03:48:04 UTC, SrMordred wrote:
 Well I just installed the VS 2017 to try the ldc and get 
 (maybe) the same error.
You didn't forget to install the Windows SDK with it, did you?
Jul 06 2018
parent reply SrMordred <patric.dexheimer gmail.com> writes:
On Friday, 6 July 2018 at 19:36:05 UTC, 0xEAB wrote:
 On Friday, 6 July 2018 at 03:48:04 UTC, SrMordred wrote:
 Well I just installed the VS 2017 to try the ldc and get 
 (maybe) the same error.
You didn't forget to install the Windows SDK with it, did you?
Yep I forgot xD It fixed the PATHs but still getting this: libcmt.lib(chkstk.obj) : fatal error LNK1112: module machine type 'X86' conflicts with target machine type 'x64' which i´m trying to solve now.
Jul 06 2018
parent reply SrMordred <patric.dexheimer gmail.com> writes:
Delete everything, installed everything again, the installation 
failed to set the proper PATH to MS link.exe, so i put it by hand 
and now get:
fatal error LNK1104: cannot open file 'libcmt.lib'

Frustrating.
Jul 06 2018
parent reply SrMordred <patric.dexheimer gmail.com> writes:
Well, since its VS 2017 installer, eventually I hit all the 
components needed to install it properly. Now its working.
Thanks 0xEAB for the tip about the Windows SDK too :)
Jul 06 2018
parent 0xEAB <desisma heidel.beer> writes:
On Friday, 6 July 2018 at 23:54:35 UTC, SrMordred wrote:
 Well, since its VS 2017 installer, eventually I hit all the 
 components needed to install it properly. Now its working.
 Thanks 0xEAB for the tip about the Windows SDK too :)
No problem :)
Jul 07 2018