www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - D static library on Windows 64 problem

reply WhatMeWorry <kheaser gmail.com> writes:
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.
Jan 02 2021
parent reply WhatMeWorry <kheaser gmail.com> writes:
On Saturday, 2 January 2021 at 22:04:28 UTC, WhatMeWorry wrote:
 I'm stepping through the windows static library tutorial at

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

 [...]
Oops. used the manual example. Should be /LIBPATH:c:\dev\LibraryStudy\StaticLibrary\libfoobar
Jan 02 2021
parent reply Imperatorn <johan_forsberg_86 hotmail.com> writes:
On Saturday, 2 January 2021 at 22:08:34 UTC, WhatMeWorry wrote:
 On Saturday, 2 January 2021 at 22:04:28 UTC, WhatMeWorry wrote:
 I'm stepping through the windows static library tutorial at

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

 [...]
Oops. used the manual example. Should be /LIBPATH:c:\dev\LibraryStudy\StaticLibrary\libfoobar
If it doesn't say so on the wiki (haven't read), could you update it with your findings? Thanks!
Jan 03 2021
parent WhatMeWorry <kheaser gmail.com> writes:
On Sunday, 3 January 2021 at 15:49:03 UTC, Imperatorn wrote:
 On Saturday, 2 January 2021 at 22:08:34 UTC, WhatMeWorry wrote:
 On Saturday, 2 January 2021 at 22:04:28 UTC, WhatMeWorry wrote:
 I'm stepping through the windows static library tutorial at

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

 [...]
Oops. used the manual example. Should be /LIBPATH:c:\dev\LibraryStudy\StaticLibrary\libfoobar
If it doesn't say so on the wiki (haven't read), could you update it with your findings? Thanks!
I'm sorry. The correction was for my first post, not the tutorial. If the tutorial was written for 64 bits I wouldn't be having this problem :)
Jan 03 2021