Download

Compile Error in 4.6 on UE Tutorial Intro to UE4 Programming

I’m following the tutorials and have come across two issues so far. The first I’ve resolved due to others encountering the same issue. This first issue resulted from the user of the macro GENERATED_BODY() which makes everything follow it private. Adding the public: keyword resolved compile issues with declaring UPROPERTY(…) macros.

I’ve also added a constructor (4.6 template code doesn’t include a constructor by default) as appears in the tutorial but with modification based on what I read in the forums.

The second issue lies with use of the UFUNCTION(). Below is my code.


UCLASS()
class TUTORIAL3RDPERSON_API APickup : public AActor
{
	GENERATED_BODY()
	
public:
	APickup(const FObjectInitializer& ObjectInitializer);
	
	// True when the pickup is able to be picked up, false if something deactivates the pickup
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Pickup)
	bool bIsActive;
	
	// Simple collision primitive to use as the root component
	UPROPERTY(VisibleDefaultsOnly, BlueprintReadOnly, Category = Pickup)
	USphereComponent* BaseCollisionComponent;
	
	// StaticMeshComponent to represent the pickup in the level
	UPROPERTY(VisibleDefaultsOnly, BlueprintReadOnly, Category = Pickup)
	UStaticMeshComponent* PickupMesh;
	
	// Function to call when the Pickup is collected
	UFUNCTION(BlueprintNativeEvent)
	void OnPickedUp();
};


If I comment out the UFUNCTION line it compiles fine but obviously that’s not how I should solve the problem. :slight_smile: Would appreciate help on this.

I’m compiling on a Mac in XCODE 6.1. The compiler error is:
Command /Users/Shared/UnrealEngine/4.6/Engine/Build/BatchFiles/Mac/RocketBuild.sh failed with exit code 2

Building Tutorial3rdPersonEditor…
Compiling game modules for hot reload
Compiling with Mac SDK 10.10
Parsing headers for Tutorial3rdPersonEditor
FMallocCrash overhead is 3780608 bytes
Reflection code generated for Tutorial3rdPersonEditor
Performing 3 actions (12 in parallel)
[1/3] Compile Tutorial3rdPerson.generated.cpp
[2/3] Compile Pickup.cpp
[3/3] Link UE4Editor-Tutorial3rdPerson-2126-Mac-DebugGame.dylib
Undefined symbols for architecture x86_64:
“vtable for APickup”, referenced from:
APickup::APickup(FObjectInitializer const&) in Pickup.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)
-------- End Detailed Actions Stats -----------------------------------------------------------
ERROR: UBT ERROR: Failed to produce item: /Volumes/Master Drobo/Mac OS X folders/Users/joe/Documents/Unreal Projects/Tutorial3rdPerson/Binaries/Mac/UE4Editor-Tutorial3rdPerson-2126-Mac-DebugGame.dylib
Cumulative action seconds (12 processors): 0.00 building projects, 5.95 compiling, 0.00 creating app bundles, 0.00 generating debug info, 0.10 linking, 0.00 other
UBT execution time: 11.19 seconds
Command /Users/Shared/UnrealEngine/4.6/Engine/Build/BatchFiles/Mac/RocketBuild.sh failed with exit code 2

Hmm, that’s weird. I compared your header file against mine and it looks the same.

Based on the output, it looks like you’re getting linker errors. The output says that the linker errors are occurring on the constructor, not your OnPickedUp() method. Does the constructor also exist in your CPP file?