MSVC linker image exceeds maximum size after upgrading JUCE

HI all!

After upgrading my project from JUCE 7.0.1 to JUCE 7.0.8, the project does not link anymore. Upon linking the SharedCode module it fails with error LNK1248:

Spline_SharedCode.lib : fatal error LNK1248: image size (1003730A3) exceeds maximum allowable size (FFFFFFFF)

After some googling for this issue I found that this 32-bit limitation still holds true, even when compiling with a 64-bit toolset. There’s nothing to be done in the linker, one has to restructure their code.

I did a bisect on the JUCE repo and found the commit where the problem first appears to be this one:

Which is a rather feature rich commit.

Notable is that this issue seems to appear only for Release config builds, probably because of additional optimizations being done.

Also noteworthy for my case might be that I’m linking in a rather large static library containing synth wavetables. The static lib is around 500MB, however the final plugin binary boils down to 80Mb. I’ve tried to compile this library with /O1 for a lighter size, to no avail.

Has anyone experienced this before or knows a workaround?
For the time being I could stay at a lower JUCE version of course, I didn’t upgrade for new features, rather to “catch up”.

A related forum post:

My own workaround has been to maintain my JUCE project files manually (as referenced in that other post you linked to).

Hoping that helps, Pete

I finally found a solution: Just ditch MSVC entirely and switch to clang.

You can try this for yourself by adding this switch to your CMake configure step:

cmake -B build -D CMAKE_BUILD_TYPE=Debug -T ClangCL

You also need to install the two clang compiler packages in your VisualStudio installer.

I was rather surprised when my entire gigantic project compiled without issues (ok some warnings) and the result just worked the very same as before. All the linking errors were just gone.

If you’re looking for a more permanent solution, you can add this to your CMakeLists (before your project() call)

# Force clang-cl on Windows + Visual Studio —
if(WIN32)
    set(_clangcl “C:/Program Files/LLVM/bin/clang-cl.exe”)
    if(NOT EXISTS “${_clangcl}”)
        message(FATAL_ERROR “clang-cl.exe not found at ${_clangcl}. Cannot build on Windows without clang-cl.”)
    endif()
    message(STATUS “Using Visual Studio generator with ClangCL toolset”)
    set(CMAKE_GENERATOR_TOOLSET “ClangCL” CACHE STRING “” FORCE)
    add_compile_options(/MP) # Enable multi-core compilation
endif()