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"

Error LNK2001 / LNK2019 / LNK1120

Hey guys, I'm getting these errors and I cannot figure out for the life of me why.

 1>LINK : error LNK2001: unresolved external symbol IMPLEMENT_MODULE_ExperienceAPI

 1>xAPIAgentComponent.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __cdecl FJsonObject::SetStringField(class FString const &,class FString const &)" (__imp_?SetStringField@FJsonObject@@QEAAXAEBVFString@@0@Z) referenced in function "public: class TSharedPtr<class FJsonObject,0> const __cdecl UxAPIAgentComponent::toAgent(void)const " (?toAgent@UxAPIAgentComponent@@QEBA?BV?$TSharedPtr@VFJsonObject@@$0A@@@XZ)

 1>xAPIAgentComponent.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __cdecl FJsonObject::SetObjectField(class FString const &,class TSharedPtr<class FJsonObject,0> const &)" (__imp_?SetObjectField@FJsonObject@@QEAAXAEBVFString@@AEBV?$TSharedPtr@VFJsonObject@@$0A@@@@Z) referenced in function "public: class TSharedPtr<class FJsonObject,0> const __cdecl UxAPIAgentComponent::toAgent(void)const " (?toAgent@UxAPIAgentComponent@@QEBA?BV?$TSharedPtr@VFJsonObject@@$0A@@@XZ)

 1>xAPIAgentComponent.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl FJsonObject::FJsonObject(void)" (__imp_??0FJsonObject@@QEAA@XZ) referenced in function "public: class TSharedPtr<class FJsonObject,0> const __cdecl UxAPIAgentComponent::toAgent(void)const " (?toAgent@UxAPIAgentComponent@@QEBA?BV?$TSharedPtr@VFJsonObject@@$0A@@@XZ)

 1>xAPIAgentComponent.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl FJsonObject::~FJsonObject(void)" (__imp_??1FJsonObject@@QEAA@XZ) referenced in function "public: virtual void __cdecl SharedPointerInternals::TReferenceControllerWithDeleter<class FJsonObject,struct SharedPointerInternals::DefaultDeleter<class FJsonObject> >::DestroyObject(void)" (?DestroyObject@?$TReferenceControllerWithDeleter@VFJsonObject@@U?$DefaultDeleter@VFJsonObject@@@SharedPointerInternals@@@SharedPointerInternals@@UEAAXXZ)

 1>F:\UnrealEngine-release\Engine\Plugins\ExperienceAPI\Binaries\Win64\UE4Editor-ExperienceAPI.dll : fatal error LNK1120: 5 unresolved externals


This is my ExperienceAPI.Build.cs

 // Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
 
 namespace UnrealBuildTool.Rules
 {
     public class ExperienceAPI : ModuleRules
     {
         public ExperienceAPI(ReadOnlyTargetRules Target) : base(Target)
         {
             PublicIncludePaths.AddRange(
                 new string[] {
                     // ... add public include paths required here ...
                 }
                 );
 
             PrivateIncludePaths.AddRange(
                 new string[] {
                     // ... add other private include paths required here ...
                 }
                 );
 
             PublicDependencyModuleNames.AddRange(
                 new string[]
                 {
                     "Core",
                     "CoreUObject",
                     "Engine",
                     // ... add other public dependencies that you statically link with here ...
                 }
                 );
 
             PrivateDependencyModuleNames.AddRange(
                 new string[]
                 {
                     // ... add private dependencies that you statically link with here ...
                 }
                 );
 
             DynamicallyLoadedModuleNames.AddRange(
                 new string[]
                 {
                     // ... add any modules that your module loads dynamically here ...
                 }
                 );
         }
     }
 }
 


Heres the xAPIAgentComponent.h

 #pragma once
 
 
 #include "Components/ActorComponent.h"
 #include "Json.h"
 #include "xAPIAgentComponent.generated.h"
 
 DECLARE_LOG_CATEGORY_EXTERN(LogXapi, Log, All);
 
 UENUM(BlueprintType)
 enum class EAgentIFIType : uint8
 {
         MBOX            UMETA(DisplayName = "mbox"),
         MBOX_SHA1SUM    UMETA(DisplayName = "mbox_sha1sum"),
         OPENID            UMETA(DisplayName = "openid"),
         ACCOUNT            UMETA(DisplayName = "account")
 };
 
 USTRUCT(BlueprintType)
 struct FAgentAccountInfo
 {
     GENERATED_USTRUCT_BODY()
 public:
     UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = ExperienceAPI)
         FString Homepage;
 
     UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = ExperienceAPI)
         FString Name;
 };
 
 /*
  * A component representing an xAPI Agent, i.e. a learner
  */
 
 UCLASS(BlueprintType, meta = (BlueprintSpawnableComponent))
 class EXPERIENCEAPI_API UxAPIAgentComponent : public UActorComponent
 {
     GENERATED_BODY()
 
 public:
 
     UPROPERTY(EditAnywhere, Category = ExperienceAPI)
         FString Name;
 
     UPROPERTY(EditAnywhere, Category = ExperienceAPI)
         EAgentIFIType ifi_type;
         //TEnumAsByte<EAgentIFIType::Type> ifi_type;
 
     UPROPERTY(EditAnywhere, Category = ExperienceAPI)
         FString Mbox;
 
     UPROPERTY(EditAnywhere, Category = ExperienceAPI)
         FString MboxSha1Sum;
 
     UPROPERTY(EditAnywhere, Category = ExperienceAPI)
         FString OpenID;
 
     UPROPERTY(EditAnywhere, Category = ExperienceAPI)
         FAgentAccountInfo Account;
 
     UxAPIAgentComponent();
 
     const TSharedPtr<FJsonObject> toAgent() const;
 };


xAPIAgentComponent.cpp

 #include "xAPIAgentComponent.h"
 
 DEFINE_LOG_CATEGORY(LogXapi);
 
 UxAPIAgentComponent::UxAPIAgentComponent()
 {
 
 }
 
 
 const TSharedPtr<FJsonObject> UxAPIAgentComponent::toAgent() const
 {
     // initialize the object we'll be returning
     TSharedPtr<FJsonObject> agent(new FJsonObject());
 
     // specify that the return object is an Agent
     agent->SetStringField(TEXT("objectType"), TEXT("Agent"));
 
     // add the general-purpose name if specified
     if (!Name.IsEmpty()){
         agent->SetStringField(TEXT("name"), Name);
     }
 
     // add the IFI specified by ifi_type
     switch (ifi_type){
     case EAgentIFIType::MBOX:
 
         agent->SetStringField(TEXT("mbox"), Mbox);
         break;
 
     case EAgentIFIType::MBOX_SHA1SUM:
 
         agent->SetStringField(TEXT("mbox_sha1sum"), MboxSha1Sum);
         break;
 
     case EAgentIFIType::OPENID:
 
         agent->SetStringField(TEXT("openid"), OpenID);
         break;
 
     case EAgentIFIType::ACCOUNT:
 
         TSharedPtr<FJsonObject> accountObj(new FJsonObject());
         accountObj->SetStringField(TEXT("homePage"), Account.Homepage);
         accountObj->SetStringField(TEXT("name"), Account.Name);
 
         agent->SetObjectField(TEXT("account"), accountObj);
         break;
     }
 
     return agent;
 }
 




Any help would be greatly appriciated!!!!

Product Version: UE 4.22
Tags:
more ▼

asked Apr 25 '19 at 02:28 PM in C++ Programming

avatar image

xCheeseonToastx
33 2 4 7

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

1 answer: sort voted first

You need to add Json to your dependencies, probably also want to add JsonUtilitie. Don't forget to regenerate your visual studio project files after adding it

  PublicDependencyModuleNames.AddRange(
             new string[] {
                      "Core",
                      "CoreUObject",
                      "Engine",
                      // ... add other public dependencies that you statically link with here ...
 
                     "Json",
                     "JsonUtilities"
             }
         );
more ▼

answered Apr 25 '19 at 02:35 PM

avatar image

Lardo Deepdelver
811 6 4 6

avatar image xCheeseonToastx Apr 25 '19 at 02:44 PM

Ill give that a go, I did have it in there previously but did not rebuild the VS project files afterwards... Will see what happens!

avatar image xCheeseonToastx Apr 25 '19 at 03:14 PM

I just get this error now

     1>LINK : error LNK2001: unresolved external symbol IMPLEMENT_MODULE_ExperienceAPI
     1>F:\UnrealEngine-release\Engine\Plugins\ExperienceAPI\Binaries\Win64\UE4Editor-ExperienceAPI.dll : fatal error LNK1120: 1 unresolved externals

As well as this

     1>  [2/6] xAPIAgentComponent.cpp
     1>F:\UnrealEngine-release\Engine\Source\Runtime\Json\Public\Json.h(10): warning : Monolithic headers should not be used by this module. Please change it to explicitly include the headers it needs.
     1>  [3/6] xAPIAgentComponent.gen.cpp
     1>F:\UnrealEngine-release\Engine\Source\Runtime\Json\Public\Json.h(10): warning : Monolithic headers should not be used by this module. Please change it to explicitly include the headers it needs.

If I take out the Json.h includes I dont get the monolithic error.

avatar image Lardo Deepdelver Apr 25 '19 at 09:37 PM

don't have the project where we use the Json module at hand, will have a look tomorrow

avatar image xCheeseonToastx Apr 25 '19 at 10:12 PM

Thanks bud, will wait and thanks for taking the time!

avatar image Lardo Deepdelver Apr 26 '19 at 09:06 AM

k looked into our project we include #include "JsonObject.h"

The error message is about only including the headers you need not everything. A good resource for finding the right headers to include is normally the unreal api documentation on the web. Google class in question "ue4 api FJsonObject" which in this case leads you here http://api.unrealengine.com/INT/API/Runtime/Json/Dom/FJsonObject/

and on the bottom under references, you see what you need to include Module + Header

For the header you need to figure out what part of the path you can leave out Runtime/Json/Public/Dom/JsonObject.h in this case apparently everything but the JsonObject.h quite often it's everything including "Public" or everything including Runtime/Engine/Classes/

avatar image xCheeseonToastx Apr 26 '19 at 02:08 PM

I've managed to fix that issue now thanks to you, the latest one that keeps popping up is to the IMPLEMENT_MODULE_ExperienceAPI. Turns out I needed to copy the module name from the - class EXPERIENCEAPI_API Ux... - to the uproject file as all caps and it compiles with no errors... Thanks for the help man

(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