UFunction causing build error

Hello everyone,

I am a complete beginner in c++ and visual studio.

the sole presence of a UFUNCTION causes error at build in the following code.
If I remove UFUNCTION, it works OK.

Searching in the forum I found similar questions (here or here or here ) but none of the answers worked for me.

As you will see from the code below, it is very basic, so I suspect a configuration problem.

I am using UE4.22, visual studio2019, the project is a blank C++ project.
the cpp file is the unchanged defaut file.

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "emptyActor.generated.h"

class BASICCPP_API AemptyActor : public AActor
	// Sets default values for this actor's properties

	// Called when the game starts or when spawned
	virtual void BeginPlay() override;

	// Called every frame
	virtual void Tick(float DeltaTime) override;

		int xyToIndex(int x, int y);

Errors :

1>------ Build started: Project: BasicCpp, Configuration: Development_Editor x64 ------
1>Creating makefile for BasicCppEditor (no existing makefile)
1>Parsing headers for BasicCppEditor
1>  Running UnrealHeaderTool "C:\Users\Jerome Boulbes\Desktop\BasicCpp\BasicCpp.uproject" "C:\Users\Jerome Boulbes\Desktop\BasicCpp\Intermediate\Build\Win64\BasicCppEditor\Development\BasicCppEditor.uhtmanifest" -LogCmds="loginit warning, logexit warning, logdatabase error" -Unattended -WarningsAsErrors -installed
1>Reflection code generated for BasicCppEditor in 5.7805036 seconds
1>Using Visual Studio 2019 14.22.27905 toolchain (C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.22.27905) and Windows 10.0.18362.0 SDK (C:\Program Files (x86)\Windows Kits\10).
1>Building 2 actions with 12 processes...
1>  [1/2] UE4Editor-BasicCpp.dll
1>     Creating library C:\Users\Jerome Boulbes\Desktop\BasicCpp\Intermediate\Build\Win64\UE4Editor\Development\BasicCpp\UE4Editor-BasicCpp.suppressed.lib and object C:\Users\Jerome Boulbes\Desktop\BasicCpp\Intermediate\Build\Win64\UE4Editor\Development\BasicCpp\UE4Editor-BasicCpp.suppressed.exp
1>emptyActor.cpp.obj : error LNK2019: unresolved external symbol "public: int __cdecl AemptyActor::xyToIndex(int,int)" (?xyToIndex@AemptyActor@@QEAAHHH@Z) referenced in function "public: static void __cdecl AemptyActor::execxyToIndex(class UObject *,struct FFrame &,void * const)" (?execxyToIndex@AemptyActor@@SAXPEAVUObject@@AEAUFFrame@@QEAX@Z)
1>emptyActor.gen.cpp.obj : error LNK2001: unresolved external symbol "public: int __cdecl AemptyActor::xyToIndex(int,int)" (?xyToIndex@AemptyActor@@QEAAHHH@Z)
1>C:\Users\Jerome Boulbes\Desktop\BasicCpp\Binaries\Win64\UE4Editor-BasicCpp.dll : fatal error LNK1120: 1 unresolved externals
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.MakeFile.Targets(44,5): error MSB3075: The command ""D:\Program Files\Epic Games\UE_4.22\Engine\Build\BatchFiles\Build.bat" BasicCppEditor Win64 Development -Project="C:\Users\Jerome Boulbes\Desktop\BasicCpp\BasicCpp.uproject" -WaitMutex -FromMsBuild" exited with code 5. Please verify that you have sufficient rights to run this command.
1>Done building project "BasicCpp.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Any help will be greatly appreciated !


I am bumping this up…

If an answer can’t be given, hint at various things to check out will be greatly appreciated !

When you declare a function in the .h (header file) you need to also implement it in the .cpp (implementation file)


      int xyToIndex(int x, int y);


int AempthyActor::xyToIndex(int x, int y)
	return 0;

Thank you ! 
It didn’t solve the problem anyway … but I am ashamed to say that I solved the problem just by installing correctly VS according to the official Unreal Engine instructions