Blank Plugin Link Error LNK2001

I have strange link errors when testing default plugin in Project.

I did this steps:

  1. I created New C++ Project (Basic Code option and with No Starter Content). Of course when I hit compile everything was ok.

  2. I’ve created new Plugin (option “Blank” ).

  3. I’ve compiled succesfuly and chose File->Refresh Visual Studio 2019 Project just for safety (and compiled once again).

  4. Next I’ve opened MyProjectGameModeBase.cpp and added

    #include "TestPlugin.h"

  5. and when I compiled I get this:

    D:\Unreal Projects\MyProject\Source\MyProject/MyProjectGameModeBase.cpp(6): fatal error C1083: file (Include) could not be opened: 'TestPlugin.h': No such file or directory

  6. So I’ve added to PublicDependencyModuleNames.AddRange in MyProject.Build.cs string “TestPlugin” so I have

    PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" , "TestPlugin"});

  7. I closed and open Editor and it compiled ok.

  8. And now fun begins. When I want to use one of Plugin default functions ( void StartupModule() ) in MyProjectGameModeBase.cpp function void test() I cannot compile because of this errors

    MyProjectGameModeBase.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl FTestPluginModule::StartupModule(void)" (?StartupModule@FTestPluginModule@@UEAAXXZ)

MyProjectGameModeBase.cpp.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl FTestPluginModule::ShutdownModule(void)" (?ShutdownModule@FTestPluginModule@@UEAAXXZ)

What should I do?

You don’t have to call StartupModule() and ShutDownModule() yourself.

This is done by the engine on the time specified in your .uplugin file under “LoadingPhase”

This video shows an example on how to make and add a class to a blank c++ plugin:

But when I create class MyActor in TestPlugin (in Unreal Editor) I get this:

Successfully added class 'MyActor', however you must recompile the 'TestPlugin' module before it will appear in the Content Browser. Failed to automatically compile the 'TestPlugin' module. Would you like to open the Output Log to see more details?

So I hit Compile in UE and it says thiat Compile is Successful but I cannot see MyActor in Content Browser in UE.
When I compile whole project in Visual Studio 2019 I get this:

Severity Code Description Project File Line Suppression State Error LNK1104 cannot open file 'D:\Unreal Projects\MyProject\Plugins\TestPlugin\Binaries\Win64\UE4Editor-TestPlugin-0001.dll' MyProject D:\Unreal Projects\MyProject\Intermediate\ProjectFiles\LINK 1

If you have a problem building after adding a new class you can try the following:

delete these folders/files in your project folder:

  • .vs
  • Binaries
  • DerivedDataCache
  • Intermediate
  • Saved
  • [YourProjectName].sln

then rightclick your .uproject file and click Generate Visual Studio Project Files
After that, try rebuilding your solution.

Ok. It works. Thank you.