There are some cases that you can trigger this unresolved external or this kind of error:
- You have the function in .h but forgot to create it in .cpp but you bind it in player input / somewhere else. Example:
Creating library D:\Game Development - C++\Mercenarian\UnrealProject\Mercenarian\Binaries\Win32\Mercenarian.lib and object D:\Game Development - C++\Mercenarian\UnrealProject\Mercenarian\Binaries\Win32\Mercenarian.exp
1>MercenarianCharacter.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall AMercenarianCharacter::Jump(void)" (?Jump@AMercenarianCharacter@@MAEXXZ)
1>Module.Mercenarian.gen.2_of_4.cpp.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall AMercenarianCharacter::Jump(void)" (?Jump@AMercenarianCharacter@@MAEXXZ)
1>D:\Game Development - C++\Mercenarian\UnrealProject\Mercenarian\Binaries\Win32\Mercenarian.exe : fatal error LNK1120: 1 unresolved externals
1>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.MakeFile.Targets(44,5): error MSB3073: The command ""C:\Program Files\Epic Games\UE_4.27\Engine\Build\BatchFiles\Build.bat" Mercenarian Win32 Development -Project="D:\Game Development - C++\Mercenarian\UnrealProject\Mercenarian\Mercenarian.uproject" -WaitMutex -FromMsBuild" exited with code 6.
1>Done building project "Mercenarian.vcxproj" -- FAILED.
That error above was occured because I have declared Jump function in .h but not in the .cpp file and I Bind it in the player input
PlayerInputComponent->BindAction("Jump", IE_Pressed, this, &AMercenarianCharacter::Jump);
If the unresolved external error show you the function name, then the error is around that function. (In my case, there is AMercenarianCharacter::Jump in the output, and that is the function that causing my error).
- You forgot / haven’t add dependecy that already used in your code. Example:
Error LNK2019 unresolved external symbol "__declspec(dllimport) public: static class UClass * __cdecl UUserWidget::StaticClass(void)" (__imp_?StaticClass@UUserWidget@@SAPEAVUClass@@XZ) referenced in function "class UUserWidget * __cdecl CreateWidget<class UUserWidget>(class UWorld *,class UClass *)" (??$CreateWidget@VUUserWidget@@@@YAPEAVUUserWidget@@PEAVUWorld@@PEAVUClass@@@Z)
In the error above, I want to use CreateWidget function but after compile it, those unresolved external symbol comes up. To fix that you need to include the dependency module needed for Widget related stuff in yourProject.Build.cs file. You can find what module you need to add by simply searching in the unreal documentation.
In this case: UUserWidget | Unreal Engine Documentation
in the Reference, you can find module that you needed.
I think there are more than two of I list above that will cause unresolved external errors, but the most unresolved external that I met usually in that case. If you meet other unresolved external, better carefully read the output and look for some hint there like the class name, functtion name or related.
I hope you fix your problem!