x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Unresolved External Symbols

I've had this problem for a couple of days now, been trying to fix it for ages, but I couldnt find anything online. Here is the .h file:

 #pragma once
 
 #include "CoreMinimal.h"
 #include "AIController.h"
 #include "Runtime/AIModule/Classes/Navigation/PathFollowingComponent.h"
 #include "PacmanGhostController.generated.h"
 
 /**
  * 
  */
 UCLASS()
 class ARCADEGAMES_API APacmanGhostController : public AAIController
 {
     GENERATED_BODY()
     
 public:
     
     APacmanGhostController();
 
     void Possess(class APawn* InPawn) override;
 
     void OnMoveCompleted(FAIRequestID RequestID, const FPathFollowingResult & Result);
     
     void SearchNewPoint();
     void GoHome();
     void Rearm();
     void StopMove();
 
 private:
     class APacmanGhost* Bot;
     FVector HomeLocation;
     FTimerHandle TimerDead;
     
 };

.cpp: #include "PacmanGhostController.h" #include "PacmanGhost.h" #include "AIController.h" #include "TimerManager.h" #include "Runtime/NavigationSystem/Public/AbstractNavData.h" #include "NavigationSystem.h"

 APacmanGhostController::APacmanGhostController() {};
 
 void APacmanGhostController::Possess(class APawn* InPawn)
 {
     Super::Possess(InPawn);
 
     Bot = Cast<APacmanGhost>(InPawn);
 
     HomeLocation = Bot->GetActorLocation();
     SearchNewPoint();
 }
 
 
 void APacmanGhostController::GoHome()
 {
     MoveToLocation(HomeLocation);
     GetWorldTimerManager().SetTimer(TimerDead, this, &APacmanGhostController::Rearm, 5.0f, false);
 }
 
 void APacmanGhostController::Rearm()
 {
 
     GetWorldTimerManager().ClearTimer(TimerDead);
     Bot->Rearm();
 
 }
 
 void APacmanGhostController::OnMoveCompleted(FAIRequestID RequestID, const FPathFollowingResult & Result)
 {
 
     if (!Bot->bIsDead) 
     { 
         SearchNewPoint();
     }
 
 }
 
 void APacmanGhostController::StopMove()
 {
 
     StopMovement();
 
 }
 
 void APacmanGhostController::SearchNewPoint()
 {
     UNavigationSystemV1* NavMesh = UNavigationSystemV1::GetCurrent(GetWorld());
     if (NavMesh)
     {
         const float SearchRadius = 10000.0f;
         FVector RandomPt;
         bool bFound = NavMesh->K2_GetRandomReachablePointInRadius(this, Bot->GetActorLocation(), RandomPt, SearchRadius);
         if (bFound)
         {
             MoveToLocation(RandomPt);
         }
     }
 }

Output:

 1>------ Build started: Project: ArcadeGames, Configuration: Development_Editor x64 ------
 1>Creating makefile for hot reloading ArcadeGamesEditor (modules to compile have changed)
 1>Compiling game modules for hot reload
 1>Using Visual Studio 2017 14.15.26726 toolchain (C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726) and Windows 10.0.16299.0 SDK (C:\Program Files (x86)\Windows Kits\10).
 1>Building 1 action with 4 processes...
 1>  [1/1] UE4Editor-ArcadeGames-1823.dll
 1>     Creating library E:\FunStuff\Unreal Engine\4Projects\1C++\ArcadeGames\Intermediate\Build\Win64\UE4Editor\Development\ArcadeGames\UE4Editor-ArcadeGames-1823.suppressed.lib and object E:\FunStuff\Unreal Engine\4Projects\1C++\ArcadeGames\Intermediate\Build\Win64\UE4Editor\Development\ArcadeGames\UE4Editor-ArcadeGames-1823.suppressed.exp
 1>PacmanGhostController.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static bool __cdecl UNavigationSystemV1::K2_GetRandomReachablePointInRadius(class UObject *,struct FVector const &,struct FVector &,float,class ANavigationData *,class TSubclassOf)" (__imp_?K2_GetRandomReachablePointInRadius@UNavigationSystemV1@@SA_NPEAVUObject@@AEBUFVector@@AEAU3@MPEAVANavigationData@@V?$TSubclassOf@VUNavigationQueryFilter@@@@@Z) referenced in function "public: void __cdecl APacmanGhostController::SearchNewPoint(void)" (?SearchNewPoint@APacmanGhostController@@QEAAXXZ)
 1>PacmanGhostController.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static class UNavigationSystemV1 * __cdecl UNavigationSystemV1::GetCurrent(class UWorld *)" (__imp_?GetCurrent@UNavigationSystemV1@@SAPEAV1@PEAVUWorld@@@Z) referenced in function "public: void __cdecl APacmanGhostController::SearchNewPoint(void)" (?SearchNewPoint@APacmanGhostController@@QEAAXXZ)
 1>E:\FunStuff\Unreal Engine\4Projects\1C++\ArcadeGames\Binaries\Win64\UE4Editor-ArcadeGames-1823.dll : fatal error LNK1120: 2 unresolved externals
 1>UnrealBuildTool : error : UBT ERROR: Failed to produce item: E:\FunStuff\Unreal Engine\4Projects\1C++\ArcadeGames\Binaries\Win64\UE4Editor-ArcadeGames-1823.dll
 1>                        (see ../Programs/UnrealBuildTool/Log.txt for full exception trace)
 1>Total build time: 89.64 seconds (Parallel executor: 0.00 seconds)
 1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.MakeFile.Targets(44,5): error MSB3075: The command ""E:\FunStuff\Unreal Engine\5Engine\UE_4.20\Engine\Build\BatchFiles\Build.bat" ArcadeGamesEditor Win64 Development "E:\FunStuff\Unreal Engine\4Projects\1C++\ArcadeGames\ArcadeGames.uproject" -WaitMutex -FromMsBuild" exited with code 5. Please verify that you have sufficient rights to run this command.
 1>Done building project "ArcadeGames.vcxproj" -- FAILED.
 ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
 

P.S. This is my first question, so if I should've included something else or left something out please tell me. Also, the reason I put all of the code in is because i'm relatively new to C++, so I'm not sure which part of the code created the error

Thanks for your time!

Product Version: UE 4.20
Tags:
more ▼

asked Oct 21 '18 at 02:45 AM in C++ Programming

avatar image

Kit Kat134
203 2 9 10

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort oldest

There 3 most common reasons why can have Unresolved External Symbols linker error:

1.You declared non-virtual function (standard function) but you didn't define code for it

2.The function is in different module and you didn't add dependency of that module in build script (*.build.cs file)

3.Class you trying to use is declared as MinimalAPI or missing extern (MODULENAME_API macro) and can not be used outside of it's module (in this case you would need to modify engine and rebuild it, possible for game projects no go for plugins)

Number 2 and 3 are UE4 specific, related to UE4 build system and it's configuration.

Your case is probably number 2, you probably missing module decency and you need to add module you using in to build script of your module. Start by checking from which module, functions or classes you using belong to, you can easily do this by searching API reference (just google class or function name and add "UE4 API", it most effective way of searching thru API reference now days). But in this case i did that for you:

https://api.unrealengine.com/INT/API/Runtime/NavigationSystem/UNavigationSystemV1/index.html

Now look below of the page you should have information in which module class is declered and in which header file, so in ourr case it is "NavigationSystem"

go to *.Build.cs file in you module inside oyur project and you will find something like this:

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

Build scripts are written in C# and this line adds decencies to the your module build rules, "Core" module contains most basic functions that you use in C++ inside UE4, "CoreUObject" contains module UObject system, root of class tree in UE4 and "Engine" is core of engine it self. Engine is divided in to more modules ("Engine" module only contains core things), you can see them as dlls in binary folder in the engine and you need to add decency if you referenceing anything from that specific module, this way UnrealBuidTool knows what to build during packaging and properly configures compilation environment for your module, so build is fully optimized.

So all you need to do is just add "NavigationSystem" to that list like this:

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

And in future oyu just add up more to this, depending what you are using, if you remove usage of some module in your module you remove it's entry here too.

more ▼

answered Oct 21 '18 at 03:50 AM

avatar image

Shadowriver
37.1k 935 172 1116

avatar image Kit Kat134 Oct 21 '18 at 04:35 AM

Thank you soooo much! Just wondering, how do I know which problem I have in the future?

avatar image Shadowriver Oct 21 '18 at 05:10 AM

1 is obviues as it will mention your function in linker error, InteliSense also will mark that function with green line in header file, if not then it most likely 2, if solution mention don't work it most likely MinimalAPI, you can confirm it by looking on header file that declares the function you use and if you sse UCLASS(...) with MinimalAPI inside then it is MinimalAPI (note that just removing that in header files is not enough you need to rebuild engine for this to take effect). But you most likely don't encounter MinimalAPI or else you gonna try to do something deeper in to engine, most actors should not lead to any of such classes, i know rendering system is full of MinimalAPI classes.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question