Error when opening copy of 5.0 to 5.1 project.

My project opens just fine in 5.0.3 but when I try to open a copy in 5.1.0 it says “The project could not be compiled. Would you like to open it in Visual Studio?” and then gives me this output:

The project could not be compiled. Would you like to open it in Visual Studio?

Running C:/Program Files/Epic Games/UE_5.1/Engine/Build/BatchFiles/Build.bat Development Win64 -Project=“C:/Users/Mitchell/Documents/GitHub/MiniAdvSourceControl/MiniAdventure 5.1/MiniAdventure.uproject” -TargetType=Editor -Progress -NoEngineChanges -NoHotReloadFromIDE
Running UnrealBuildTool: dotnet “…..\Engine\Binaries\DotNET\UnrealBuildTool\UnrealBuildTool.dll” Development Win64 -Project=“C:/Users/Mitchell/Documents/GitHub/MiniAdvSourceControl/MiniAdventure 5.1/MiniAdventure.uproject” -TargetType=Editor -Progress -NoEngineChanges -NoHotReloadFromIDE
Log file: C:\Users\Mitchell\AppData\Local\UnrealBuildTool\Log.txt
Using ‘git status’ to determine working set for adaptive non-unity build (C:\Users\Mitchell\Documents\GitHub\MiniAdvSourceControl).
Creating makefile for MiniAdventureEditor (no existing makefile)
@progress push 5%
Parsing headers for MiniAdventureEditor

  • Running Internal UnrealHeaderTool “C:\Users\Mitchell\Documents\GitHub\MiniAdvSourceControl\MiniAdventure 5.1\MiniAdventure.uproject” “C:\Users\Mitchell\Documents\GitHub\MiniAdvSourceControl\MiniAdventure 5.1\Intermediate\Build\Win64\MiniAdventureEditor\Development\MiniAdventureEditor.uhtmanifest” -WarningsAsErrors -installed*
    Total of 4 written
    Reflection code generated for MiniAdventureEditor in 0.8592182 seconds
    @progress pop
    Building MiniAdventureEditor…
    Using Visual Studio 2022 14.33.31630 toolchain (C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629) and Windows 10.0.19041.0 SDK (C:\Program Files (x86)\Windows Kits\10).
    [Upgrade]
    [Upgrade] Using backward-compatible include order. The latest version of UE has changed the order of includes, which may require code changes. The current setting is:
    [Upgrade] IncludeOrderVersion = EngineIncludeOrderVersion.Unreal5_0
    [Upgrade] Suppress this message by setting ‘IncludeOrderVersion = EngineIncludeOrderVersion.Unreal5_1;’ in MiniAdventureEditor.Target.cs.
    [Upgrade] Alternatively you can set this to ‘EngineIncludeOrderVersion.Latest’ to always use the latest include order. This will potentially cause compile errors when integrating new versions of the engine.
    [Upgrade]
    Determining max actions to execute in parallel (12 physical cores, 24 logical cores)
  • Executing up to 12 processes, one per physical core*
    Building 10 actions with 10 processes…
    [1/10] Resource Default.rc2
    [2/10] Compile SharedPCH.Engine.ShadowErrors.InclOrderUnreal5_0.cpp
    [3/10] Compile OcclusionAwarePlayerController.cpp
    C:\Users\Mitchell\Documents\GitHub\MiniAdvSourceControl\MiniAdventure 5.1\Intermediate\Build\Win64\UnrealEditor\Inc\MiniAdventure\UHT\OcclusionAwarePlayerController.generated.h(13): fatal error C1189: #error: “OcclusionAwarePlayerController.generated.h already included, missing ‘#pragma once’ in OcclusionAwarePlayerController.h”
    [4/10] Compile MyClass.cpp
    [5/10] Compile MiniAdventure.cpp
    [6/10] Compile MiniAdventure.init.gen.cpp
    [7/10] Compile OcclusionAwarePlayerController.gen.cpp
    [8/10] Link UnrealEditor-MiniAdventure.lib cancelled
    [9/10] Link UnrealEditor-MiniAdventure.dll cancelled
    [10/10] WriteMetadata MiniAdventureEditor.target cancelled

This means you must rebuild the project in visual studio before you can use it.
Right click the .uproject file and select “generate visual studio files”. After it finishes open the generated .sln file in visual studio and build the code. that’s all.

Edit* Also make sure the project is set to version 5.1 before you generate the visual studio files. you can do so by right clicking the .uproject and choose “switch unreal engine version”

1 Like

Thanks for the response. I followed your steps exactly.

After I change the version and regenerate the vs files, I opened the newly generated .sln and clicked “Build Solution”.

These are the 2 errors I get:

Edit* Also, here is the header file in question and the beginning of the .cpp file.


#pragma once must be before any #include and must be present in all .h files.

Your 2 header files confuse me. Besides what I posted earlier your includes don’t make sense. Either you are including OcclusionAwarePlayerController.generated.h in the wrong header, or you are trying to include OcclusionAwarePlayerController.h in itself (OcclusionAwarePlayerController.h) which are both very wrong.

I’ve been confused all day. I actually don’t know where these came from? I didn’t make them in my project. Any advice where to go next?

OcclusionAwarePlayerController is not an engine file as far as I know. Must be somewhere in your project or in a plugin. The first picture looks OK ( it starts with pragma once, then lastly it includes the .generated file for itself (same name as header + .generated)). The second pic does both wrong (pragma once is not first, it seems to include either itself (don’t do that) or it includes the wrong .generated file (for another header)). You should fix the includes on the second pic.

Tried fixing up the #include on the .cpp file (second photo from above). I just don’t understand what is going on. These are the errors I get from trying to build.

On that screenshot’s error tab you can set the dropdown Build + Intellisense to only Build. Intellisense will show a lot of garbage even when there are no actual errors.

Now that you show more of the screen in that screenshot I also see that this file is not a header file but a .cpp file. cpp files do not use #pragma once, that is just for the .h files. You also don’t include .generated.h headers in the cpp file. See if fixing all that reduces the error count. You should also look up a tutorial on the web so you understand when and where to do things such as includes because this is very important, else you will run into many errors after a small mistake.

Thanks for the help. I ended up copying the project folder. Deleting the header and .cpp file that had the compiling errors then opened a copy with UE 5.1. It worked fine and nothing changed in my project.

Appreciate the suggestions and advice.