UE5 LNK2001 unresolved external symbol Solution

UE5 LNK2001 unresolved external symbol Errors

Here’s how to solve unreal engine unresolved external symbol error:

LNK2001 error is thrown by Visual Studio Linker after the developer has attempted to inherit from or use a class that’s not in the module dependency list. It is a C++ Linker error meaning that the linker failed to find either the .cpp or .obj needed to link. The developer has to make sure to include all the modules containing the code that is referenced by his CPP files. Follow this simple step-by-step tutorial to solve it.

Example Error Line.

LNK2001 unresolved external symbol “public: virtual enum EMovieSceneServerClientMask __cdecl UMovieSceneSequence::OverrideNetworkMask(enum EMovieSceneServerClientMask)const … etc.

How to solve it

  1. Read Error Code To Get The Class Causing The Error

UE5 LNK2001 Error Solution Step 1

The unreal engine unresolved external symbol error usually contains a class name followed by the function the Linker can’t find. In this unreal engine tutorial, we are mostly interested in the class.  Copy it and follow on. I have highlighted the class in our example error.  These errors seem cryptic at first encounter. You just need to know where to look and ignore the rest. In some cases, only the function is reported without the class. That is still fine, we can use that too.

  1. Locate the class in the unreal engine documentation

Most of the time, googling the class will lead you straight to the documentation page about the class on the unreal engine website. What we are looking for in the documentation page is the module name that this class belongs to. Googling the class is the fastest and easiest way I recommend to find the class. In our example we would be searching for  “UMovieSceneSequence” 

Sometimes though, rarely, you will not be able to find through Google or website. What you can do, is use the Find in Files Function of visual studio and search for the Class definition. We are interested in the header file where this class is defined. 

UE5 LNK2001 How to use Find In Files for class
  1. Find the module in the unreal engine documentation

At this point, you are either on the documentation page of the class or on the header file. We need to spot and copy the module name from here. 

On the documentation page/website the module we need to add to the build path is usually listed under “References”. In our example, we determined the missing module’s name to be MovieScene See the image below:.

UE5 How to locate class module on documentation page

Alternatively, If you’re on the header file, all you need to do is look at the on-disk path of the header file. The name we need is usually what appears after “Engine/Source/Runtime/”. See the image below:

UE5 LNK2001 How to find required module
  1. Add the module to the project’s Build.cs file

Final Step: We copy the module name and it to the PrivateDependencyModuleNames. Here is an example entry.

 

PrivateDependencyModuleNames.AddRange(new string[] { “LevelSequence” , “MovieScene” });

 

At this point you may be wondering what’s the difference between UE5 PrivateDependencyModuleNames and the PublicDependencyModuleNames. You can learn more about the difference in our Plugin Development Course.

That’s it. Now when you rebuild the unreal engine unresolved external symbol error will be solved.