Vtable compiler error

Undefined symbols for architecture x86_64:
“vtable for ATest2Character”, referenced from:
ATest2Character::ATest2Character() in Test2Character.cpp.o
ATest2Character::ATest2Character(FVTableHelper&) in Test2Character.gen.cpp.o
ATest2Character::ATest2Character(FVTableHelper&) in Test2Character.gen.cpp.o
ATest2Character::__VTableCtorCaller(FVTableHelper&) in Test2Character.gen.cpp.o
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Command /Users/Shared/Epic Games/UE_4.22/Engine/Build/BatchFiles/Mac/XcodeBuild.sh failed with exit code 5

I started following a tutorial and the compiler started not liking code that was already put in and it worked before. This is code the unreal engine had already put in (thirdperson character template) and idk what to do, ive been stuck on this for about 3 days now. Note, i did add health functions because im trying to add health and a stamina bar, maybe im going about it the wrong way and it doesnt like it. Im not sure. Ill post the code here:
// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.

#pragma once

#include “Core.h”
#include “GameFramework/Character.h”
#include “Test2Character.generated.h”

UCLASS(config=Game)
class ATest2Character : public ACharacter
{
GENERATED_BODY()

/** Camera boom positioning the camera behind the character */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true"))
class USpringArmComponent* CameraBoom;

/** Follow camera */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true"))
class UCameraComponent* FollowCamera;

public:
ATest2Character();

virtual void Tick(float DeltaTime) override;

/** Base turn rate, in deg/sec. Other scaling may affect final turn rate. */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category=Camera)
float BaseTurnRate;

/** Base look up/down rate, in deg/sec. Other scaling may affect final rate. */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category=Camera)
float BaseLookUpRate;

private:
//Character Attributes
UPROPERTY(EditAnywhere,Category=Attributes)
float Health = 1.0f;
UPROPERTY(EditAnywhere,Category=Attributes)
float Stamina = 1.0f;
UPROPERTY(EditAnywhere,Category=Attributes)
FString PlayerName = “”;
protected:

/** Resets HMD orientation in VR. */
void OnResetVR();

/** Called for forwards/backward input */
void MoveForward(float Value);

/** Called for side to side input */
void MoveRight(float Value);

/** 
 * Called via input to turn at a given rate. 
 * @param Rate	This is a normalized rate, i.e. 1.0 means 100% of desired turn rate
 */
void TurnAtRate(float Rate);

/**
 * Called via input to turn look up/down at a given rate. 
 * @param Rate	This is a normalized rate, i.e. 1.0 means 100% of desired turn rate
 */
void LookUpAtRate(float Rate);

/** Handler for when a touch input begins. */
void TouchStarted(ETouchIndex::Type FingerIndex, FVector Location);

/** Handler for when a touch input stops. */
void TouchStopped(ETouchIndex::Type FingerIndex, FVector Location);

public:
//get health and stamina functions
UFUNCTION(Blueprintpure, category = Attributes)
float GetHealth();
UFUNCTION(Blueprintpure, category = Attributes)
float GetStamina();
UFUNCTION(Blueprintpure, category = Attributes)
float GetCurrentHealth();
UFUNCTION(Blueprintpure, category = Attributes)
float GetCurrentStamina();
UFUNCTION(Blueprintpure, category = Attributes)
FString GetPlayerName();

protected:
// APawn interface
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
// End of APawn interface

public:
/** Returns CameraBoom subobject /
FORCEINLINE class USpringArmComponent
GetCameraBoom() const { return CameraBoom; }
/
* Returns FollowCamera subobject */
FORCEINLINE class UCameraComponent
GetFollowCamera() const { return FollowCamera; }
};

never touched any Virtutal functions nor any VTables its talking about. I tried to figure this out on my own but its getting out of hand. Please help!

You have 1 virtual method in there:

protected: // APawn interface 
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override; // End of APawn interface

Do you have a body defined for that method?

Yes here it is:

void ATest2Character::SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent)
{
// Set up gameplay key bindings
check(PlayerInputComponent);
PlayerInputComponent->BindAction(“Jump”, IE_Pressed, this, &ACharacter::Jump);
PlayerInputComponent->BindAction(“Jump”, IE_Released, this, &ACharacter::StopJumping);

PlayerInputComponent->BindAxis("MoveForward", this, &ATest2Character::MoveForward);
PlayerInputComponent->BindAxis("MoveRight", this, &ATest2Character::MoveRight);

// We have 2 versions of the rotation bindings to handle different kinds of devices differently
// "turn" handles devices that provide an absolute delta, such as a mouse.
// "turnrate" is for devices that we choose to treat as a rate of change, such as an analog joystick
PlayerInputComponent->BindAxis("Turn", this, &APawn::AddControllerYawInput);
PlayerInputComponent->BindAxis("TurnRate", this, &ATest2Character::TurnAtRate);
PlayerInputComponent->BindAxis("LookUp", this, &APawn::AddControllerPitchInput);
PlayerInputComponent->BindAxis("LookUpRate", this, &ATest2Character::LookUpAtRate);

// handle touch devices
PlayerInputComponent->BindTouch(IE_Pressed, this, &ATest2Character::TouchStarted);
PlayerInputComponent->BindTouch(IE_Released, this, &ATest2Character::TouchStopped);

// VR headset functionality
PlayerInputComponent->BindAction("ResetVR", IE_Pressed, this, &ATest2Character::OnResetVR);

}

its straight from unreal so im confused as to why it would be upset with this code

Omg i got it, i had added a virtual void and i didnt define it, thank god i found it. Thank you! You helped because now i was looking specifically for virtual voids i had

1 Like

This one had me going as well. Turns out, if you mark any UPROPERTY Variable as “Replicate” you must also add a definition for GetLifetimeReplicatedProps(). Hope this helps anyone with a similar problem

1 Like