Issue 21447 - Undocumented MS linker error LNK1377
Summary: Undocumented MS linker error LNK1377
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All Windows
: P3 normal
Assignee: No Owner
URL:
Keywords: industry
Depends on:
Blocks:
 
Reported: 2020-12-02 15:38 UTC by kinke
Modified: 2022-12-17 10:37 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description kinke 2020-12-02 15:38:27 UTC
Trying to link a huge project compiled with DMD v2.094.2 for Win64 yields:

extra.lib(mutation_bb3e_d85.obj) : fatal error LNK1377: '_D8kaleidic3sil3std5extra5chart6ggplot4Plot4saveMFAyaiiZv' symbol not found in object. The containing library is corrupt.

Note that this isn't the usual LNK2019 ('unresolved external symbol ... referenced in function ...'). Googling 'LNK1377' only yields 28 (unrelated) results. Compiling with LDC v1.24.0 works fine.

Additionally, the symbol *is* defined in that extra.lib. `dumpbin /symbols extra.lib`:

017 00000000 UNDEF  notype ()    External     | _D8kaleidic3sil3std5extra5chart6ggplot4Plot4saveMFAyaiiZv
...
017 00000000 UNDEF  notype ()    External     | _D8kaleidic3sil3std5extra5chart6ggplot4Plot4saveMFAyaiiZv
...
085 00000000 SECTB  notype ()    External     | _D8kaleidic3sil3std5extra5chart6ggplot4Plot4saveMFAyaiiZv
086 00000000 SECTC  notype       Static       | $unwind$_D8kaleidic3sil3std5extra5chart6ggplot4Plot4saveMFAyaiiZv
087 00000000 SECTD  notype       Static       | $pdata$_D8kaleidic3sil3std5extra5chart6ggplot4Plot4saveMFAyaiiZv

To me, 'symbol not found in object' sounds like the linker expects the symbol to be defined in the same object file.

Unfortunately I can't really provide a testcase, not even binary artifacts - the lib is huge (~288 MB), the dumpbin output >3M lines...
Comment 1 Walter Bright 2020-12-12 00:53:09 UTC
> The containing library is corrupt.

Instead of using dmd to build the library, try building it with Microsoft's lib tool.
Comment 2 Per Nordlöw 2020-12-14 23:04:05 UTC
(In reply to Walter Bright from comment #1)
> > The containing library is corrupt.
> 
> Instead of using dmd to build the library, try building it with Microsoft's
> lib tool.

I would greatly appreciate if you could explain

- how the call to dub changes and
- what command line call I should use to link the resulting binary using "lib tool". "lib tool" doesn't seem to be an official linker name on Windows. Which other linker are you referring to?
Comment 3 Walter Bright 2020-12-19 00:18:23 UTC
Here's the Microsoft lib tool that comes with Visual Studio:

C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC>lib
Microsoft (R) Library Manager Version 10.00.40219.01
Copyright (C) Microsoft Corporation.  All rights reserved.

usage: LIB [options] [files]

   options:

      /DEF[:filename]
      /ERRORREPORT:{NONE|PROMPT|QUEUE|SEND}
      /EXPORT:symbol
      /EXTRACT:membername
      /INCLUDE:symbol
      /LIBPATH:dir
      /LIST[:filename]
      /LTCG
      /MACHINE:{ARM|EBC|IA64|MIPS|MIPS16|MIPSFPU|MIPSFPU16|
                SH4|THUMB|X64|X86}
      /NAME:filename
      /NODEFAULTLIB[:library]
      /NOLOGO
      /OUT:filename
      /REMOVE:membername
      /SUBSYSTEM:{BOOT_APPLICATION|CONSOLE|EFI_APPLICATION|
                  EFI_BOOT_SERVICE_DRIVER|EFI_ROM|EFI_RUNTIME_DRIVER|
                  NATIVE|POSIX|WINDOWS|WINDOWSCE}[,#[.##]]
      /VERBOSE
      /WX[:NO]

And a link to what it does and how to use it:

https://docs.microsoft.com/en-us/cpp/build/reference/lib-reference?view=msvc-160

I don't know how your project is creating libraries, but when the message says "the containing library is corrupt" that's where to start.