diff --git a/src/common/cutscenes/movieplayer.cpp b/src/common/cutscenes/movieplayer.cpp index a1b04385f..bfe5cf7b9 100644 --- a/src/common/cutscenes/movieplayer.cpp +++ b/src/common/cutscenes/movieplayer.cpp @@ -52,6 +52,8 @@ #include #include "filereadermusicinterface.h" +void LinkMoviePlayer() { } + class MoviePlayer { protected: diff --git a/src/common/engine/date.cpp b/src/common/engine/date.cpp index 63e3776b7..452b31dbf 100644 --- a/src/common/engine/date.cpp +++ b/src/common/engine/date.cpp @@ -40,6 +40,7 @@ time_t epochoffset = 0; // epoch start in seconds (0 = January 1st, 1970) +void LinkDate() { } //========================================================================== // diff --git a/src/common/objects/autosegs.cpp b/src/common/objects/autosegs.cpp index e9b3f935f..49408dc0b 100644 --- a/src/common/objects/autosegs.cpp +++ b/src/common/objects/autosegs.cpp @@ -81,6 +81,28 @@ AUTOSEG_VARIABLE(CVarDecl, AUTOSEG_VREG) #undef AUTOSEG_STOP #undef AUTOSEG_START +void LinkVMThunksActors(); +void LinkVMIterators(); +void LinkDynArrays(); +void LinkMaps(); +void LinkDate(); +void LinkPPShader(); +void LinkMoviePlayer(); +void LinkPlayermenu(); + +void LinkUnreferencedZScriptGlobals() +{ + // The linker in C++ only links .obj files from static libraries that it can find direct references to. + // Some source files contain no external references so we have to force the linkage. + LinkVMThunksActors(); + LinkVMIterators(); + LinkDynArrays(); + LinkMaps(); + LinkDate(); + LinkPPShader(); + LinkMoviePlayer(); + LinkPlayermenu(); +} void FAutoSeg::Initialize() { diff --git a/src/common/rendering/hwrenderer/postprocessing/hw_postprocessshader.cpp b/src/common/rendering/hwrenderer/postprocessing/hw_postprocessshader.cpp index 0e2b8d8cf..d9534a3d4 100644 --- a/src/common/rendering/hwrenderer/postprocessing/hw_postprocessshader.cpp +++ b/src/common/rendering/hwrenderer/postprocessing/hw_postprocessshader.cpp @@ -23,6 +23,8 @@ #include "hwrenderer/postprocessing/hw_postprocessshader.h" #include "hwrenderer/postprocessing/hw_postprocess.h" +void LinkPPShader() { } + static void ShaderSetEnabled(const FString &shaderName, bool value) { for (unsigned int i = 0; i < PostProcessShaders.Size(); i++) diff --git a/src/common/scripting/core/dynarrays.cpp b/src/common/scripting/core/dynarrays.cpp index 207c91fbc..b0d458062 100644 --- a/src/common/scripting/core/dynarrays.cpp +++ b/src/common/scripting/core/dynarrays.cpp @@ -39,6 +39,8 @@ #include "types.h" #include "v_draw.h" +void LinkDynArrays() { } + // We need one specific type for each of the 8 integral VM types and instantiate the needed functions for each of them. // Dynamic arrays cannot hold structs because for every type there'd need to be an internal implementation which is impossible. diff --git a/src/common/scripting/core/maps.cpp b/src/common/scripting/core/maps.cpp index bed5110de..16760ce88 100644 --- a/src/common/scripting/core/maps.cpp +++ b/src/common/scripting/core/maps.cpp @@ -6,6 +6,7 @@ #include "v_draw.h" #include "maps.h" +void LinkMaps() { } //========================================================================== // diff --git a/src/gamemain.cpp b/src/gamemain.cpp index 934e4b50b..79c3916a9 100644 --- a/src/gamemain.cpp +++ b/src/gamemain.cpp @@ -1,4 +1,6 @@ +void LinkUnreferencedZScriptGlobals(); + #if defined(WIN32) #define WIN32_MEAN_AND_LEAN @@ -8,6 +10,7 @@ int I_GameMain(HINSTANCE hInstance, HINSTANCE nothing, LPWSTR cmdline, int nCmdS int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE nothing, LPWSTR cmdline, int nCmdShow) { + LinkUnreferencedZScriptGlobals(); return I_GameMain(hInstance, nothing, cmdline, nCmdShow); } @@ -17,6 +20,7 @@ int I_GameMain(int argc, char** argv); int main(int argc, char** argv) { + LinkUnreferencedZScriptGlobals(); return I_GameMain(argc, argv); } diff --git a/src/menu/playermenu.cpp b/src/menu/playermenu.cpp index 07192a2d9..ae0303368 100644 --- a/src/menu/playermenu.cpp +++ b/src/menu/playermenu.cpp @@ -41,6 +41,8 @@ #include "vm.h" #include "d_player.h" +void LinkPlayermenu() { } + EXTERN_CVAR(Int, team) EXTERN_CVAR(Float, autoaim) EXTERN_CVAR(Bool, neverswitchonpickup) diff --git a/src/scripting/vmiterators.cpp b/src/scripting/vmiterators.cpp index 32d1ca1f8..f7938a435 100644 --- a/src/scripting/vmiterators.cpp +++ b/src/scripting/vmiterators.cpp @@ -30,6 +30,8 @@ #include "g_levellocals.h" #include "vm.h" +void LinkVMIterators() { } + //========================================================================== // // scriptable thinker iterator diff --git a/src/scripting/vmthunks_actors.cpp b/src/scripting/vmthunks_actors.cpp index 2cf04fd80..9e257ffe9 100644 --- a/src/scripting/vmthunks_actors.cpp +++ b/src/scripting/vmthunks_actors.cpp @@ -57,6 +57,8 @@ #include "gi.h" #include "shadowinlines.h" +void LinkVMThunksActors() { } + DVector2 AM_GetPosition(); int Net_GetLatency(int *ld, int *ad); void PrintPickupMessage(bool localview, const FString &str);