D static library on Windows 64 problem

WhatMeWorry kheaser at gmail.com
Sat Jan 2 22:04:28 UTC 2021


I'm stepping through the windows static library tutorial at

http://prowiki.org/wiki4d/wiki.cgi?D__Tutorial/CompilingLinkingD#Linkingmanually

```
The fix is to specify the prebuilt .lib file on the command line:

     dmd driver.d %cd%\libs\libfoo\libfoo.lib
```

The tutorial is for 32 bit so it uses OPTLINK.  I'm using 64 bits 
so it uses Microsoft's link.exe  When I try

dmd -m64 -v driver.d 
-L=/LIBPATH:"c:\dev\LibraryStudy\StaticLibrary\libfoobar"

I get this monstrosity

link.exe /NOLOGO "driver.obj"   /DEFAULTLIB:phobos64 
/LIBPATH:"c:\dev\LibraryStudy\StaticLibrary\libfoobar" /OPT:NOICF 
  /LIBPATH:"C:\Program Files (x86)\Microsoft Visual 
Studio\2019\BuildTools\VC\Tools\MSVC\14.27.29110\lib\x64" 
legacy_stdio_definitions.lib /LIBPATH:"C:\Program Files 
(x86)\Windows Kits\10\Lib\10.0.18362.0\ucrt\x64" 
/LIBPATH:"C:\Program Files (x86)\Windows 
Kits\10\lib\10.0.18362.0\um\x64"

which I think would work except for the fact the path argument 
looses its double quotes.

Is there a fix?

I tried invoking link.exe directly with the ""s added manually, 
but then link.exe complains that phobos64.lib can't be found.



More information about the Digitalmars-d-learn mailing list