From c2379acd7a9f1de3d4c444cfcc209178ccee5461 Mon Sep 17 00:00:00 2001 From: "Marco Antonio J. Costa" Date: Wed, 22 Jul 2026 15:01:48 -0300 Subject: [PATCH] link the executable the same way whatever generator builds it Two link settings were conditional on the Visual Studio generator, though what they compensate for is the prebuilt libraries in the tree, which are the same libraries under every generator. Ninja builds got away with it because link.exe is quiet about both; lld-link is not. legacy_stdio_definitions.lib: RakNetLibStatic.lib still calls _vsnprintf, which the UCRT only exports through that compatibility library. /SAFESEH:NO: lua51.lib and the smackw32 import library carry no safe exception handler table, so no linker can emit one. The image never had it. Before and after, JA2.exe reports SEHandlerTable 0x0 and SEHandlerCount 0, with DYNAMIC_BASE, NX_COMPAT and TERMINAL_SERVER_AWARE unchanged -- the flag states what link.exe was already doing silently. Dbghelp.lib and Winmm.lib are also spelled as the SDK ships them, since a cross-compile looks for them on a case sensitive filesystem. --- CMakeLists.txt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 997fd42f6..b74165cc7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -81,8 +81,8 @@ set(Ja2_Libraries "${CMAKE_SOURCE_DIR}/libexpatMT.lib" "${CMAKE_SOURCE_DIR}/lua51.lib" "${CMAKE_SOURCE_DIR}/lua51.vc9.lib" -"Dbghelp.lib" -"Winmm.lib" +"dbghelp.lib" +"winmm.lib" "ws2_32.lib" bfVFS Lua @@ -146,8 +146,12 @@ foreach(app IN LISTS ApplicationTargets) sgp/sgp.cpp Ja2/Res/ja2.rc ) - target_link_libraries(${exe} PRIVATE ${Ja2_Libraries} $) - target_link_options(${exe} PRIVATE $) + # RakNetLibStatic.lib was built against an older CRT and still calls + # _vsnprintf, which the UCRT only exports through this compatibility library. + target_link_libraries(${exe} PRIVATE ${Ja2_Libraries} legacy_stdio_definitions.lib) + # The prebuilt lua51.lib and smackw32 import library carry no safe exception + # handler table, so the image cannot claim one whatever links it. + target_link_options(${exe} PRIVATE /SAFESEH:NO) target_compile_definitions(${exe} PRIVATE ${compilationFlags} ${debugFlags}) # language library for the application, e.g. JA2MAPEDITOR_i18n — one per app, all 8