Download

Error: identifier "GEngine" is undefined

Hi there,

i’m currently starting to work with UE4. I wanted to create some DebugMessages and i’ve seen these one in this format:

GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Green, FString::FString("PlaneRotation.Roll = ") + FString::SanitizeFloat(PlaneRotation.Roll));

If u click on the image, you see “GEngine” is underlined red and I get the following message: Error: identifier “GEngine” is undefined

This snippet is extracted from the Tick Function. I used the Flying-Project, from the Starter-Content and didn’t add much content.

How can i fix this?

Another question: Can I implement this debug message in a way, that i only see one line when testing(which also gets updated) and not 100 due to the “Tick-Function”?

Thanks for your help,
smara :slight_smile:

Are you sure it’s not an Intellisense issue? That Error is from hovering the red underline or from building output? If it’s the first case, try building it.

Error List after trying to build:

Solution: https://forums.unrealengine.com/showthread.php?30502-4-4-What-happened-to-EngineGlobals-h&highlight=gengine

Due to the update from 4.3.1 -> 4.4 GEngine is not public anymore(see Link)

[FONT=Comic Sans MS]Solution

GEngine is still alive and well and still public.

The issue is actually really simple! (though it did have me confused for a good 20 minutes once I started a new 4.4 project)

New projects have this in their MyProject.h


#include "EngineMinimal.h"

Replace the above with this


#include "Engine.h"

and you will have GEngine back again :slight_smile:

Rama

2 Likes

Woo! You’re the best Rama. (First post)
In the beginning stages of my first oculus rift + UE4 game

Congrats on your first Post!

Welcome to the forums!

:slight_smile:

Rama

Lifesaver!

Save your compile time or go for a coffee!

Please don’t include the whole Engine if you don’t need it.

EngineMinimal.h gives you all you need. If something is in any file missing it is much better
to include it only there and not for the whole module.

So if you want to save compile time and want to have the missing GEngine please include following:


#include "Runtime/Engine/Public/EngineGlobals.h"

There is the GEngine declared being an extern variable – meaning: GEngine* is somewhere, global static, in the memory.

Hope that helps!

2 Likes

This didnt fix the error. Instead it threw an “UEngine undefined type” Error. According to internet posts this is fixed by including “Engine.h” instead of “EngineMinimal.h”. Is this really the only way?

UEngine is defined in “Engine/Engine.h”

I realize that is a bit confusing but it is a different file inside the classes folder rather than the public folder.

Also you should be able to use “EngineGlobals.h” instead of the full path.

Edit: First of all you need to understand what is happening here. I don’t think you do. The basic “Engine.h” merely includes a bunch of other files. Find the file on your disk at “Source\Runtime\Engine\Public\Engine.h” and open it to see what it is doing.

The point of the advice being given is to not include all of those other headers that you don’t actually need since it just inflates your compile time.

The error you receive means that you did not include the header file where UEngine was defined. You can find that in “Source\Runtime\Engine\Classes\Engine.h”.

With the way compilation works, you only need to specify part of the path in your source file. So this is what you would need:

#include “EngineGlobals.h”
#include “Engine/Engine.h”

Truth to be told, I really did not think about it yesterday myself :open_mouth: We need to include the class UEngine expliclity of course, since we (or me in this case) access a member of GEngine… Forward declarations are of course not enough in such a case.

Though I did not know about the shorter include paths, thank you very much :wink: Sorry about my thoughtlessness

#include “Engine/Engine.h” will be the right way to include!

Has anyone successfully included GEngine in the most recent versions of Unreal (4.23 specifically)? I’ve tried the different combinations of #includes suggested above and nothing seems to be working.

if
#include “Engine/Engine.h”
or
#include “Engine.h”

does not work for you then there is something wrong with your installation.

Some nice header files were made specially for that and make importing the whole engine less necessary, this way you simply import what you need which makes everything run better in the end. The line that Dwarfmine suggested is one of them and should make GEngine work.


#include "Runtime/Engine/Public/EngineGlobals.h"

You could also replace with this line with the one below since everything in the public path should be available right away when you include:


#Include "EngineGlobals.h"

I only use AddOnScreenDebugMessage so far since I am following the fps C++ tutorial and fixing the errors I get as they come in, but it should still work.

If a declaration is missing something I would recommend is trying to find it in the documentation wiki. It is better to include only what you need to save compilation time rather than include the whole thing and possibly cause other problems along the way.
But then again, I am not using the UEngine declaration, I only needed GEngine.

Hopefully it helped ^^