I have strange link errors when testing default plugin in Project.
I did this steps:
-
I created New C++ Project (Basic Code option and with No Starter Content). Of course when I hit compile everything was ok.
-
I’ve created new Plugin (option “Blank” ).
-
I’ve compiled succesfuly and chose File->Refresh Visual Studio 2019 Project just for safety (and compiled once again).
-
Next I’ve opened MyProjectGameModeBase.cpp and added
#include "TestPlugin.h"
-
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
-
So I’ve added to
PublicDependencyModuleNames.AddRange
inMyProject.Build.cs
string “TestPlugin” so I havePublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" , "TestPlugin"});
-
I closed and open Editor and it compiled ok.
-
And now fun begins. When I want to use one of Plugin default functions (
void StartupModule()
) inMyProjectGameModeBase.cpp
functionvoid test()
I cannot compile because of this errorsMyProjectGameModeBase.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?