Can error "fatal error LNK1107: invalid or corrpt file" be caused by a static library file that is too large?

  • Thread starter Thread starter dgelknglkeglk
  • Start date Start date
D

dgelknglkeglk

Guest
I have a Solution in Visual Studio 2015 that has 2 x64 Projects: one builds a static library and one builds a console executable that uses the library. I'm using Windows 10, 64bit edition. I'm trying to build both Release and Debug configurations.

In both cases the static library is quite large, over 2 GB.

Initially, I was getting this error from Visual Studio when linking: "fatal error LNK1104: cannot open file 'C:\blah\blah\blah.lib'".

From looking on the web, it looked like I had to tell Visual Studio to use the x64 native tools in order to link to static library files this large. So I have added this line to both configurations in the .vcxproj file:

<PreferredToolArchitecture>x64</PreferredToolArchitecture>

Indeed, by adding the 'preferred tool architecture' line to the .vcxproj file, I solved that error for both Release and Debug configurations.

So, now the Debug configuration builds and runs as expected.

However, the Release version now reports the "LNK1107" error mentioned in the title. I have replicated the error multiple times on multiple computers, so it's not happenstance. Is it possible that Visual Studio is building a corrupt static library file?

It's easier for me to believe that the error has to do with the file size rather than Visual Studio building a corrupt file consistently. But, the Debug static library file is actually substantially bigger than the Release version (around 3.2 GB for debug vs. 2.4 GB for release). So, if Visual Studio can use the bigger static library file in debug mode, shouldn't it be able to use a smaller version for release?

I guess another possibility is that the static library file format is wrong. But, I've checked the properties of the release build vs. the debug build quite carefully and don't see any differences.

Can you suggest any other issues that might cause the LNK1107 error?

Thanks for any help.

-tom

Continue reading...
 
Back
Top