2
votes

In Release mode, Visual Studio 2015 is giving me an error about a corrupt static library file, while in Debug mode, it does not. I've carefully compared the settings of each mode, and do not find any differences that I think would cause this.

Here is the actual error: C:\repositories\svn\code\Main\Libraries\WindowLib\x64\Release\WindowLib.lib : fatal error LNK1107: invalid or corrupt file: cannot read at 0x37F5C5C

Everything I have found on the web and SO seems to indicate that this error stems from accidentally linking to a .dll instead of a static lib, or that the .lib file is corrupt.

The file is definitely not a .dll - so all the questions/answers regarding that as a solution don't apply.

As for it being corrupt, I'm not sure why or how Visual Studio would create a corrupt static lib file. I've tried it on 2 different computers, multiple times, and the error is consistent. That doesn't seem to indicate a corrupt file.

Since this exact same setup used to work correctly, I'm leaning toward thinking that this has to do with the size of the static library file (which is just over 2 GB). However:

1) The static .lib file built in debug mode is larger (3.5 GB), and it links just fine.

2) I haven't seen any references to file size causing this type of error (Visual Studio seems to report something more like "I can't file this file" or "I can't open this file" when the files are too large).

3) I've carefully implemented all the settings from the Visual Studio Debug mode in the Release mode that seemed to help with file size issues.

1

1 Answers

1
votes

Just in case this helps anyone else...

This does indeed seem to be a bug in the x64 linker for Visual Studio 2015.

I changed my code to create 2 static library files instead of 1, where each was about half the size. After that, I ended up with two .lib files of about 1.2 GB each. I did not change any other settings for the Visual Studio projects.

The release version then linked fine, as the debug version had been doing all along.

I can't think of any explanation for why the debug version could link a 3.5 GB file, while the release version could not even link a 2.4 GB, other than a glitch in the linker code.