4.15 C++ Transition Guide

Guys, can someone tell me, are you actually getting a compiler warning/error about including Engine.h? I’ve added the following to my Build.cs files:



PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
bEnforceIWYU = true;


I’m getting the new behaviour (no module PCH used) but I can still include Engine.h and use GEngine without issue. Wondering what I’m missing?

Also, confused by 's solution. The GEngine pointer is declared in the same header as the UEngine class, so if you can’t include that header, then creating another extern declaration won’t help because without the class definition, you can’t access any members or methods anyway. The fact there are two Engine.h files doesn’t help much (Engine/Classes/Engine.h and Engine/Public/Engine.h). The former includes the class and GEngine, but it’s the latter that is the monolithic header which presumably we’re no longer supposed to be including.

Hi all, I have a similar issue to earlier in this thread, when i drop my plugins into a 4.15 project, visual studio cannot find any of the headers. Adding bEnforceIWYU = false; should help, right? but it doesn’t. Do I need to rewrite every class to upgrade? Ug.

EDIT. Yes, yes i do. :slight_smile: rebuilding the plugins without the PCH is the way forward.

We’re getting the check() in DataChannel.cpp:1523 halting our game now when we remove some of our objects from the scene. The ‘bKeepReplicators’ input param is being set to true by (updated in 4.15) line 1707.

Any idea what use case this change was meant to fix and what we’re doing wrong ?

Cheers.

You are right.
I did include Engine/Engine.h instead of the public Engine.h and I got no warnings!

I also can include the public Engine.h even if I set bEnforceIWYU too; maybe it’s not fully enforcing us for now :confused:

Edit:

So I’ve ended up doing this; seems to work:



#include "CoreMinimal.h"
#include "UObject/Object.h"
#include "UObject/WeakObjectPtr.h"
#include "Runtime/Engine/Classes/Engine/Engine.h"


Yeah, it’s a little embarrasing the number of things we refer to as “Engine”. It’s all legacy, unfortunately. There’s the top-level Engine folder, then the engine module, then the giant Engine/Public/Engine.h header, then there’s the definition of UEngine and GEngine in Engine/Classes/Engine/Engine.h.

The way to include the latter (definition of GEngine and UEngine) is to include “Engine/Engine.h”.

@kamrann && [MENTION=434]BrUnO XaVIeR[/MENTION]

Thanks for sharing your further research, I’ve updated my original post with Ben’s confirmation of the solution you found :slight_smile:

You’re welcome, and hi @DamirH ! So nice to have you around!

Thank you for explaining Ben!

:heart:

1 Like

Oh my this sounds serious!

I hope Epic sees this :slight_smile:

1 Like

Has anyone ran into this? I only get this in a packaged build…

The only place im using std is with my sql wrapper and i need the vectors as part of the call back to the sqlite lib.

Is IWYU meant for gameplay code? Everything I see is referencing engine and plugin/module compile times, but nothing specifically referencing code outside that scope. Is it worth going through the trouble and converting my project to IWYU?

Well, your game modules will also compile faster if you do.

At a guess, the library you’re wrapping has been configured/built to use C++ exceptions, which I believe are disabled by UBT in shipping builds.

Aside from possible compilation time reduction (it’s probably not going to be very significant at the project level), the main reason why the new approach is better practice is that if all headers are self contained, you avoid potentially annoying errors when including headers in multiple modules which have differing precompiled headers. So if your project is a single module or has minimal sharing of code across modules, then switching over probably isn’t a big deal.

Urgh, has the file system path been somehow changed?

Since we upgraded to 4.15, our package game cannot load anything with StaticLoadObject() with the “/Game/…” anymore.

Is there a way enable exceptions?

Or perhaps the SQLite library im using needs to be removed of said exceptions?

Yeah, everything I have tried to get a command line dedicated server build has failed. Something has changed in the build chain and none of the different ways I have done command lines works anymore. I think it is specifically a problem bcause, like you, I don’t have the project under the engine directory.

Its driving me nuts.

Update: As per my issue I had to include:

#include <memory>

and all was well.

Since I transitionned our project to UE 4.15 I experience very long time to build the project, even when I just update the CPP file.

In UE 4.14 in took less than 16 seconds…
Now it takes around 55 seconds.

What I changed in the code base was to remove the include to engine.h in our main header file, and replaced that line by CoreMinimal.h. I also added a few includes in the game code where needed.

I tried to play with the flag bEnforceIWYU in the build.cs file, but either true and false make the build last much longer…

I also have this error in the log of visual studio 2015 when I build:

This does not prevent the editor from successfully hot-reloading the code, but when I attach VS to the editor I can’t step in the code like I could do in UE 4.14.

We’ll revert to UE 4.14.3, waiting for things to behave better, maybe in a future patch?

In the nean time I have entered a bug report here : Slow build time with UE 4.15 - Programming & Scripting - Epic Developer Community Forums

Can’t move my project to 4.15 because of: “Couldn’t find parent type for ‘OST_WheeledVehicle’ named ‘AWheeledVehicle’ in current module or any other module parsed so far.”
Looks like problem in my OST_Character.h Can someone help please?


1>------ Сборка начата: проект: UE4, Конфигурация: BuiltWithUnrealBuildTool Win32 ------
2>------ Сборка начата: проект: OST_Game, Конфигурация: Development_Editor x64 ------
2>  Creating makefile for hot reloading OST_GameEditor (no existing makefile)
2>  Compiling game modules for hot reload
2>  Performing full C++ include scan (no include cache file)
2>  Parsing headers for OST_GameEditor
2>    Running UnrealHeaderTool "C:\Users\Anna\Documents\Unreal Projects\OST_Game\OST_Game.uproject" "C:\Users\Anna\Documents\Unreal Projects\OST_Game\Intermediate\Build\Win64\OST_GameEditor\Development\OST_GameEditor.uhtmanifest" -LogCmds="loginit warning, logexit warning, logdatabase error" -Unattended -WarningsAsErrors -installed
2>EXEC : error : Couldn't find parent type for 'OST_WheeledVehicle' named 'AWheeledVehicle' in current module or any other module parsed so far.
2>C:/Users/Anna/Documents/Unreal Projects/OST_Game/Source/OST_Game/OST_Character.h(365): error : Unrecognized type 'AWheeledVehicle' - type must be a UCLASS, USTRUCT or UENUM
2>EXEC : error : UnrealHeaderTool failed for target 'OST_GameEditor' (platform: Win64, module info: C:\Users\Anna\Documents\Unreal Projects\OST_Game\Intermediate\Build\Win64\OST_GameEditor\Development\OST_GameEditor.uhtmanifest, exit code: OtherCompilationError (5)).
2>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.MakeFile.Targets(37,5): error MSB3075: Выход из команды ""Z:\Epic Games\UE_4.15\Engine\Build\BatchFiles\Build.bat" OST_GameEditor Win64 Development "C:\Users\Anna\Documents\Unreal Projects\OST_Game\OST_Game.uproject" -waitmutex" с кодом 5. Убедитесь в наличии достаточных прав для выполнения данной команды.
========== Сборка: успешно: 1, с ошибками: 1, без изменений: 0, пропущено: 0 ==========

This should be an easy fix, just enable the vehicle plugin and you should be good to go. For 4.15, vehicle support was moved into a separate plugin.

I added in my OST_Game.project:
“Plugins”:
{
“Name”: “PhysXVehicles”,
“Enabled”: true
}
But nothing happen, still same: “Couldn’t find parent type for ‘OST_WheeledVehicle’ named ‘AWheeledVehicle’ in current module or any other module parsed so far.”

I am getting unresolved externals, because I include some landscape calls in my script:


CompilerResultsLog:Error: Error WorldMapMassImporter.cpp.obj : error LNK2019: unresolved external symbol "public: void __cdecl FEdModeLandscape::SetCurrentToolMode(class FName,bool)" (?SetCurrentToolMode@FEdModeLandscape@@QEAAXVFName@@_N@Z) referenced in function "public: void __cdecl UWorldMapMassImporter::PopulateRoadSplines(void)" (?PopulateRoadSplines@UW
orldMapMassImporter@@QEAAXXZ)
CompilerResultsLog:Error: Error WorldMapMassImporter.cpp.obj : error LNK2019: unresolved external symbol "public: void __cdecl FEdModeLandscape::SetCurrentTool(class FName)" (?SetCurrentTool@FEdModeLandscape@@QEAAXVFName@@@Z) referenced in function "public: void __cdecl UWorldMapMassImporter::PopulateRoadSplines(void)" (?PopulateRoadSplines@UWorldMapMassImpo
rter@@QEAAXXZ)
CompilerResultsLog:Error: Error E:\UnrealFantasyGit\UnrealFantasy\Binaries\Win64\UE4Editor-UnrealFantasy-3874.dll : fatal error LNK1120: 2 unresolved externals

But but but but, I have landscape included in build taget! :



        PublicDependencyModuleNames.AddRange(new string] { "Core", "CoreUObject", "Engine", "InputCore", "UMG", "Slate", "SlateCore","AIModule","GameplayTasks", "Blutility", "UnrealEd", "ContentBrowser", "SlateCore", "LevelEditor", "ImageWrapper", "Landscape", "LandscapeEditor", "Foliage", "ViewportInteraction"});
        PrivateDependencyModuleNames.AddRange(new string] { "LandscapeEditor" });

What else I might be missing? Some other dependancy? Is there some alrogythm/proven way to track down what I am missing? I can not figure anything from that error I get.