1

Visual Studio 2015 can not link bigger than 2G static library.

The error is:

Can not find *.lib file.

My question is: Is it designed to? If so,why?

Cœur
  • 37,241
  • 25
  • 195
  • 267
keyou
  • 43
  • 6
  • 1
    You are likely using the 32-bit hosted tools, You can opt-in to using the x64 native versions of the tools which should have more success. ``set PreferredToolArchitecture=x64`` and then launch ``devenv.exe`` or add ``x64`` to the vcxproj right after ``Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />``. See [this thread](https://stackoverflow.com/questions/19820718/how-to-make-visual-studio-use-the-native-amd64-toolchain). – Chuck Walbourn Jun 15 '17 at 07:33
  • Thanks,it works for me. – keyou Jun 23 '17 at 07:52

1 Answers1

2

The 32-bit tools can only use 2 GB of virtual address space (although they are /LARGEADDRESSAWARE so technically on the 64-bit OS they can get 3 GB of virtual space). As such, the linker is likely just exhausting virtual address space on such a large library.

The solution is to use the x64 native tools instead of the 32-bit ones.

Either set an environment variable:

set PreferredToolArchitecture=x64

Or edit your vcxproj to add the following to your project file right after <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />

<PropertyGroup>
    <PreferredToolArchitecture>x64</PreferredTool‌​Architecture>
</Prope‌​rtyGroup>

See Sponsored Feature: RAM, VRAM, and More RAM: 64-Bit Gaming Is Here for the details on virtual address space limits in 32-bit vs. 64-bit apps.

Chuck Walbourn
  • 38,259
  • 2
  • 58
  • 81
  • A side note after trying this and succeeded: the property definition does not need to be after the `Import`. I also succeeded in putting `x64` in the global `PropertyGroup` before ``. – Harry Summer Nov 20 '18 at 20:56