x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

Game Instance - Unresolved External Symbol

Hi guys

I'm pretty new to C++, and following through a tutorial book which has got me creating a new Game Instance class (RPGGameInstance), but I'm having an error each time I try to compile.

Here's what I've got in the header file:

 #pragma once
 
 #include "Engine/GameInstance.h"
 #include "RPGGameInstance.generated.h"
 
 UCLASS()
 class RPG_API URPGGameInstance : public UGameInstance
 {
     GENERATED_BODY()
 
         URPGGameInstance(const class FObjectInitializer& ObjectInitializer);
 };
 

I can't see anything wrong with it, and I've used ObjectInitializer in the exact same way for another class, and it works perfectly.

When I hover above the "UCLASS()" declaration, Intellisense says "this declaration has no storage class or type specifier", and when I hover above the "class" declaration below it, it says "expected a ;".

When I look at the UE4 Message Log, I get this:

 Error RPGGameInstance.cpp.obj : error LNK2019: unresolved external symbol "private: __cdecl URPGGameInstance::URPGGameInstance(class FObjectInitializer const &)" (??0URPGGameInstance@@AEAA@AEBVFObjectInitializer@@@Z) referenced in function "public: static void __cdecl URPGGameInstance::__DefaultConstructor(class FObjectInitializer const &)" (?__DefaultConstructor@URPGGameInstance@@SAXAEBVFObjectInitializer@@@Z)
 

Does anybody have any idea what's going wrong here?

Any information will be appreciated!

Cheers

Fallen

Product Version: UE 4.11
Tags:
more ▼

asked Apr 16 '16 at 03:19 PM in C++ Programming

avatar image

AnarkiUK
72 4 6 10

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Well, typically after asking for help, I found out the issue. I just needed to put this into the .cpp for that class:

 URPGGameInstance::URPGGameInstance(const class FObjectInitializer& objectInitializer) : Super(objectInitializer)
 {
 
 }
more ▼

answered Apr 16 '16 at 03:31 PM

avatar image

AnarkiUK
72 4 6 10

avatar image ryanjon2040 Apr 16 '16 at 03:53 PM

Just a quick note. When using GENERATED_BODY() macro you dont need need to use the FObjectInitializer. You can declare the method like this:

URPGGameInstance();

avatar image AnarkiUK Apr 16 '16 at 04:33 PM

Thanks, ryanjon2040 - Good to know :)

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question