Skip to content

Can't build epmodel on MSVC - LINK : fatal error LNK1189: library limit of 65535 objects exceeded #5631

Description

@jmarrec

Description

With os-4.0-dev branch, which has both epmodel and model, we CANNOT build with MSVC.

LINK : fatal error LNK1189: library limit of 65535 objects exceeded

This is a hard MSVC linker limit on the number of objects/members it can pack into a .lib (used when generating the import library for openstudiolib.dll).

MSVC uses a 16-bit unsigned integer (like it's 1980...), and they have no plans to change that: https://developercommunity.visualstudio.com/t/fix-msvc-65535-symbol-limit-in-lib-files-lnk1189/220174

Removing model doesn't even work, as epmodel has more symbols than model, and we were dangerously close to the limit already without knowing it (I already tried that).

In build dir, I basically:

Got every .obj that is going to be linked by looking at the content of build_dir/CMakeFiles/openstudiolib.rsp

Called `dumpbin /nologo /directives <path/to/File.cpp.obj>" for each obj file, retaining on the directives that start by "/EXPORT:", and finally de-dupped the symbols, and aggregated per library.

library unique symbols
openstudio_epmodel 60,399
openstudio_model 52,758
openstudio_utilities 6,364
openstudio_airflow 1,999
openstudio_energyplus 779
Everything else combined 1,482

Total unique exported symbols in openstudiolib.dll: 123,781. Limit is 65,535 — we're at ~1.9×, so reducing it is pretty much hopeless.

Before epmodel, model + everything else totaled 123,781 − 60,399 = 63,382 unique symbols — just barely under the 65,535 ceiling. epmodel alone adds 60,399, blowing straight past it

Current Behavior

[ 25%][2933/11530] Linking CXX shared library Products\openstudiolib.dll
FAILED: [code=4294967295] Products/openstudiolib.dll Products/openstudiolib.lib
C:\WINDOWS\system32\cmd.exe /C "cd . && "C:\Program Files\CMake\bin\cmake.exe" -E vs_link_dll --msvc-ver=1944 --intdir=src\lib\CMakeFiles\openstudiolib.dir --rc="C:\Program Files (x86)\Windows Kits\10\bin\10.0.26100.0\x64\rc.exe" --mt="C:\Program Files (x86)\Windows Kits\10\bin\10.0.26100.0\x64\mt.exe" --manifests  -- "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.44.35207\bin\Hostx64\x64\link.exe" /nologo @CMakeFiles\openstudiolib.rsp  /out:Products\openstudiolib.dll /implib:Products\openstudiolib.lib /pdb:Products\openstudiolib.pdb /dll /version:0.0 /machine:x64 /INCREMENTAL:NO && cd ."
LINK: command "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.44.35207\bin\Hostx64\x64\link.exe /nologo @CMakeFiles\openstudiolib.rsp /out:Products\openstudiolib.dll /implib:Products\openstudiolib.lib /pdb:Products\openstudiolib.pdb /dll /version:0.0 /machine:x64 /INCREMENTAL:NO /MANIFEST:EMBED,ID=2" failed (exit code 1189) with the following output:
LINK : fatal error LNK1189: library limit of 65535 objects exceeded
[ 25%][2939/11530] Building CXX object src\model\CMakeFiles\ruby_OpenStudioModelResources.dir\ruby_OpenStudioModelResources_wrap.cxx.obj
ninja: build stopped: subcommand failed.

Expected Behavior

It should build

Steps to reproduce

checkout the os-4.0-dev branch and try to build wiht MSVC...

Possible Solution

We will have to split into several DLLs on windoze...

Operating System affected

Windows 10, Windows 11

Environment

I tested on

  • Platform (Operating system, version, architecture): Microsoft Windows 10 Pro 10.0.19045 22H2 AMD64
  • Windows 11 Arm64

Version of OpenStudio

os-4.0-dev, 7a780a

Context

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions