LNK2019 errors when building standalone with plugin

I created a project from one of the pre-made samples (third person shooter, specifically), and created a very simple plugin which would print the FPS as a debug message. I’m trying to compile it as a standalone executable. It works in Play In Editor, but when trying to Launch the game from the editor or build from Visual Studio using the Development configuration (as opposed to DevelopmentEditor) it fails. I get the following error:

1>UELinkerFixups.cpp.obj : error LNK2019: unresolved external symbol "void __cdecl EmptyLinkFunctionForStaticInitializationMyPlugin(void)" (?EmptyLinkFunctionForStaticInitializationMyPlugin@@YAXXZ) referenced in function "void __cdecl UELinkerFixups(void)" (?UELinkerFixups@@YAXXZ)
1>C:\Users\cognimancer\Documents\Unreal Projects\AppTest0\Binaries\Win64\AppTest.exe : fatal error LNK1120: 1 unresolved externals

On the other hand, when I right click the MyPlugin.uproject file and select Launch Game, it launches in a window - looks a lot like a standalone exe, but I don’t see an executable being generated anywhere.

What might be causing this? The plugin uses no third party libraries, and removing the FPS printout code doesn’t help it run. It looks like a problem between the engine and the plugin, but the plugin works fine in the editor. I’ve tried DebugGame and Development configs, both in x64.

The plugin is as barebones as I can make it, pretty much just the minimum code needed for a plugin.

MyPlugin.Build.cs

using UnrealBuildTool;
using System.IO;
 
public class MyPlugin : ModuleRules
{

Path.GetDirectoryName(RulesCompiler.GetModuleFilename(this.GetType().Name)); }

    public MyPlugin(TargetInfo Target)
    {
        PrivateIncludePaths.AddRange(new string[] { "MyPlugin/Private", "MyPlugin/Classes" });
 
        PublicDependencyModuleNames.AddRange(new string[] { "Engine", "Core", "CoreUObject" });
    }
}

MyPlugin.uplugin

{
    "FileVersion" : 1,
 
    "FriendlyName" : "Test Plugin",
    "Version" : 1,
    "VersionName": "1.0",
    "EngineVersion" : "4.4",
    "Description" : "Prints FPS to screen."
    "Category" : "Runtime",
    "CreatedBy" : "cognimancer",
 
    "Modules" :
    [
        {
            "Name" : "MyPlugin",
            "Type" : "Runtime"
        } 
    ]
}

Found the problem! It was in my _______Plugin.cpp file, where the IMPLEMENT_MODULE macro is used. I was giving it Module as the second argument (not sure where that came from, probably copied from sample code), when it should have been given MyPlugin.

I also ran into this problem and it took me a bit to figure out. Your solution wasn’t the same as my solution.

My issue: in my root folder I have a source file which is named [ProjectName].cpp (in my case, “magemaster2.cpp”).
Within there, was a line which said:

IMPLEMENT_PRIMARY_GAME_MODULE( FDefaultGameModuleImpl, MageMaster, "MageMaster" );

This is wrong. The game module needs to reflect the project name, so I changed it to:

IMPLEMENT_PRIMARY_GAME_MODULE( FDefaultGameModuleImpl, MageMaster2, "MageMaster2" );

and it worked.

I have no idea how this got changed or why it wasn’t causing problems in the past. Regardless, this is where you should look if you get these types of linker errors.