LNK2001 Changing Function Parameters

I tried to change the parameters of a function and I cannot compile for the life of me. I tried changing it from no arguments to 3 strings. It compiles nicely when I change the parameters back to void. I made sure to remove all blueprint and C++ references to the function but I can’t get rid of this linker error.

I have tried:

  • Changing solution configuration
  • Refreshing visual studio project
  • “Generate visual studio project” by right clicking on the project file.
  • Deleting the binaries (won’t let me launch the project)

The output:

CompilerResultsLog: Error: HowDareFunctionLibrary.gen.cpp.obj : error LNK2001: unresolved external symbol "public: void __cdecl UGameAccountObject::AccountLogin(void)" (?AccountLogin@UGameAccountObject@@QEAAXXZ)
CompilerResultsLog: Error: HowDareGameInstance.gen.cpp.obj : error LNK2001: unresolved external symbol "public: void __cdecl UGameAccountObject::AccountLogin(void)" (?AccountLogin@UGameAccountObject@@QEAAXXZ)
CompilerResultsLog: Error: HowDareFunctionLibrary.cpp.obj : error LNK2001: unresolved external symbol "public: void __cdecl UGameAccountObject::AccountLogin(void)" (?AccountLogin@UGameAccountObject@@QEAAXXZ)
CompilerResultsLog: Error: HowDareGameInstance.cpp.obj : error LNK2001: unresolved external symbol "public: void __cdecl UGameAccountObject::AccountLogin(void)" (?AccountLogin@UGameAccountObject@@QEAAXXZ)
CompilerResultsLog: Error: HowDarePlayerCharacter.cpp.obj : error LNK2001: unresolved external symbol "public: void __cdecl UGameAccountObject::AccountLogin(void)" (?AccountLogin@UGameAccountObject@@QEAAXXZ)
CompilerResultsLog: Error: HowDareSaveGame.cpp.obj : error LNK2001: unresolved external symbol "public: void __cdecl UGameAccountObject::AccountLogin(void)" (?AccountLogin@UGameAccountObject@@QEAAXXZ)
CompilerResultsLog: Error: E:\Documents\Unreal Projects\HowDare\Binaries\Win64\UE4Editor-HowDare-3947.dll : fatal error LNK1120: 1 unresolved externals
CompilerResultsLog: ERROR: UBT ERROR: Failed to produce item: E:\Documents\Unreal Projects\HowDare\Binaries\Win64\UE4Editor-HowDare-3947.dll

Unfortunately I don’t really know what to do with the output. Please help!

Edit: to clarify: the function causing issues is:

UGameAccountObject::AccountLogin(void)

Hi,
could you post the part of the code in HowDareGameInstance.cpp where you use the UGameAccountObject
And the .h of UGameAccountObject, there might be a DLL external symbol link missing.

For sure! Let me know if there is anything else you’d like to look at.

HowDareGameInstance.cpp:

#include "HowDareGameInstance.h"



UHowDareGameInstance::UHowDareGameInstance() {
	this->PlayerGameAccount = NewObject<UGameAccountObject>();
	this->PlayerObject = NewObject<UHowDarePlayerObject>();
}

UGameAccountObject.h:

#pragma once

#include "Json.h"
#include "NetworkObject.h"
#include "HashFunctionLibrary.h"
#include "NetworkFunctionLibrary.h"

#include "CoreMinimal.h"
#include "UObject/NoExportTypes.h"
#include "GameAccountObject.generated.h"

DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FLoginDataReceivedSignature, const FString&, ErrorString, int32, ErrorCode);


/**
 * 
 */
UCLASS(Blueprintable)
class HOWDARE_API UGameAccountObject : public UObject
{
	GENERATED_BODY()

	public:
		//Constructor
		UGameAccountObject();

		//Login functions
		UFUNCTION(BlueprintCallable, Category = "Account Functions")
			void AccountLogin(const FString& uEmail, const FString& uUsername, const FString& uPassword);
		UFUNCTION()
			void AccountLoginComplete(const FString& HttpData);
		UPROPERTY(BlueprintAssignable, Category = "Account Functions")
			FLoginDataReceivedSignature AccountLogin_OnReceived;	
};

Edit: note AccountLogin() used to take no parameters. I added 3 strings and can no longer compile

and you changed also the declaration in UGameAccountObject.cpp ?

And just to understand, both classes are in the same VS project?

Yeah I sure did. I tried changing it to an empty function but here is the function in UGameAccountObject.cpp:

void UGameAccountObject::AccountLogin(const FString& uEmail, const FString& uUsername, const FString& uPassword) {

}

Sigh… I fixed the problem by going to Build->Rebuild Solution. Clearly something was cached somewhere that wouldn’t get refreshed. I tried to rebuild the project in every other way for hours but that did the trick!

ok, I was going to ask you that as link problem was refering AccountLogin(void) and not AccountLogin(const FString&,…)
A good rebuild in VS is always useful when nothing works :wink:

I have noticed a couple of times with 4.17, I will have to delete my intermediate folder for my project as some of the .gen.cpp files get mashed up and don’t work.

Sometimes, delete intermediate, regenerate project, build works. Saves having to do a full rebuild.