I have the errors LNK2019 and LNK1120 when I build my C++ BlueprintFuctionLibrary. I don’t know how to fix these errors and hope, that someone can help me.
MyBlueprintFunctionLibrary.h :
#pragma once
#include "Sockets.h"
#include "Networking.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "MyBlueprintFunctionLibrary.generated.h"
/**
*
*/
UCLASS()
class INVENTORY_API UMyBlueprintFunctionLibrary : public UBlueprintFunctionLibrary
{
GENERATED_BODY()
public:
UFUNCTION(BlueprintPure, Category = "Network")
static bool sendStringToServer(FString adress, int32 port, FString Text);
};
MyBlueprintFunctionLibrary.cpp :
#include "Inventory.h"
#include "Sockets.h"
#include "Networking.h"
#include "MyBlueprintFunctionLibrary.h"
bool sendStringToServer(FString adress, int32 port, FString Text) {
FSocket* Socket = ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM)->CreateSocket(NAME_Stream, TEXT("default"), false);
FIPv4Address ip;
FIPv4Address::Parse(adress,ip);
TSharedRef<FInternetAddr> addr = ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM)->CreateInternetAddr();
addr->SetIp(ip.GetValue());
addr->SetPort(port);
bool connected = Socket->Connect(*addr);
TCHAR *serializedChar = Text.GetCharArray().GetData();
int32 size = FCString::Strlen(serializedChar);
int32 sent = 0;
bool successful = Socket->Send((uint8*)TCHAR_TO_UTF8(serializedChar), size, sent);
return successful;
}
Build.cs :
using UnrealBuildTool;
public class Inventory : ModuleRules
{
public Inventory(TargetInfo Target)
{
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" ,"Networking","Sockets"});
PrivateDependencyModuleNames.AddRange(new string[] { });
// Uncomment if you are using Slate UI
// PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });
// Uncomment if you are using online features
// PrivateDependencyModuleNames.Add("OnlineSubsystem");
// if ((Target.Platform == UnrealTargetPlatform.Win32) || (Target.Platform == UnrealTargetPlatform.Win64))
// {
// if (UEBuildConfiguration.bCompileSteamOSS == true)
// {
// DynamicallyLoadedModuleNames.Add("OnlineSubsystemSteam");
// }
// }
}
}
Error Message:
MyBlueprintFunctionLibrary.cpp.obj : error LNK2019: unresolved external symbol “public: static bool __cdecl UMyBlueprintFunctionLibrary::sendStringToServer(class FString,int,class FString)” (?sendStringToServer@UMyBlueprintFunctionLibrary@@SA_NVFString@@H0@Z) referenced in function “public: void __cdecl UMyBlueprintFunctionLibrary::execsendStringToServer(struct FFrame &,void * const)” (?execsendStringToServer@UMyBlueprintFunctionLibrary@@QEAAXAEAUFFrame@@QEAX@Z)
1>Inventory.generated.cpp.obj : error LNK2001: unresolved external symbol “public: static bool __cdecl UMyBlueprintFunctionLibrary::sendStringToServer(class FString,int,class FString)” (?sendStringToServer@UMyBlueprintFunctionLibrary@@SA_NVFString@@H0@Z)
1>C:\Users\Julian\Documents\Unreal Projects\Inventory\Binaries\Win64\UE4Editor-Inventory-5300.dll : fatal error LNK1120: 1 unresolved externals