My unreal engine code wont compile

Hello. I am new to unreal engine. and when I want to build my project with a game mode base I am greeted to this error:

Severity Code Description Project File Line Suppression State Details
Error MSB3073 The command C:\Program Files\Epic Games\UE_5.4\Engine\Build\BatchFiles\Build.bat MyProject17Editor Win64 Development -Project=C:\Users\Bohlen4\Documents\Unreal Projects\MyProject17\MyProject17.uproject -WaitMutex -FromMsBuild -architecture=x64 exited with code 6. MyProject17 C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.MakeFile.Targets 44

Also, I think unreal engine is supposed to create a game mode base by default, but my unreal engine doesn’t do that, so I have to create it is that a problem? (I’m using unreal engine in C++)
And I have installed every needed package for visual studio and my graphic’s driver is up to date
Also, unreal engine runs fine (No lagging)
I have tried to remove plugins, but it didn’t work
I’m using C++ UE 5.4.2 Visual studio 2022 latest version
I have these installed on my visual studio:
ASP .NET and web development
Node.js development
.NET desktop development
Desktop development with C++
Windows application development
Game development with Unity
Data storage and processing
Data science and analytical application
Linux and embedded development with C++
here’s the .uproject file:

	"FileVersion": 3,
	"EngineAssociation": "5.4",
	"Category": "",
	"Description": "",
	"Modules": [
		{
			"Name": "MyProject17",
			"Type": "Runtime",
			"LoadingPhase": "Default",
			"AdditionalDependencies": [
				"Engine"
			]
		}
	],
	"Plugins": [
		{
			"Name": "ModelingToolsEditorMode",
			"Enabled": true,
			"TargetAllowList": [
				"Editor"
			]
		}
	]
}

if I clean the project then build it these errors come up:

Severity Code Description Project File Line Suppression State Details
Error (active) CS0246 The type or namespace name ‘UnrealBuildTool’ could not be found (are you missing a using directive or an assembly reference?) ScriptGeneratorUbtPlugin.ubtplugin C:\Program Files\Epic Games\UE_5.4\Engine\Plugins\ScriptPlugin\Source\ScriptGeneratorUbtPlugin\ScriptCodeGeneratorBase.cs 12
Severity Code Description Project File Line Suppression State Details
— — — — — — — —
Error MSB3073 The command C:\Program Files\Epic Games\UE_5.4\Engine\Build\BatchFiles\Build.bat MyProject17Editor Win64 Development -Project=C:\Users\Bohlen4\Documents\Unreal Projects\MyProject17\MyProject17.uproject -WaitMutex -FromMsBuild -architecture=x64 exited with code 6. MyProject17 C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.MakeFile.Targets 44

how did you add your game mode class? the suggested method for any class you want the Editor to see, or will have Generated_Body, the initial file should be added through the editor (each other object in the “same file” you can just add without much issue
Tools->New C++ Class... selecting the base class: in this game Game Mode or Game Mode Base (depending on how much of the AGameMode you don’t like even though you could still inherit from AGameMode and then override its functions and just not call the parent class) this will generate the .gen and fill in a the majority of the boiler plate that could easily be missed. you could even change your mind on everything about the class, and it will still “work” in most cases, but creating the .gen files is a mine-field, and easy to break (so it is strongly suggested to not create or manually modify them

AGameModeBase and AGameMode are part of the engine and included in the binaries ([EngineInstall]\Engine\Source\Runtime\Engine\Classes\GameFramework\GameMode.h), after inheriting from one of those you should then be matching up with updating your project settings after you have a successful build.

1 Like

if you are running the editor with LiveCoding enabled then DO NOT use the Visual Studio Build/Debug buttons while the Editor is running, and only compile from the editor while the editor is open.

LiveCoding on its own can be fine as long as you do not modify the header files, and use the editor’s compile button. you can still close the editor and recompile especially if you are getting unexpected behavior, or are modifying header files.

I will also advise that even with disabling LiveCoding you still want to close the editor to rebuild/recompile, because the error messages withing the editor are not as helpful especially lacking the double click to jump to option.

for things like modifying order of operation, or rapid iteration of functions LiveCoding can be fine, just don’t trust to be able to save editor changes especially if you modified a header file relative to the thing being saved or you will have data loss.

1 Like

Though Disabling the live coding feature works for the gamemode base but when I want to include the Camera component (include <Camera/CameraComponent>) It still errors and says:

Severity Code Description Project File Line Suppression State Details
Error (active) E0020 identifier FTextureBuildSettings is undefined MyProject6 C:\Program Files\Epic Games\UE_5.4\Engine\Source\Runtime\Engine\Classes\Engine\Texture.h 2017
Error (active) E1455 member function declared with ‘override’ does not override a base class member MyProject6 C:\Program Files\Epic Games\UE_5.4\Engine\Source\Runtime\Core\Public\Serialization\ArchiveProxy.h 157
Error (active) E1455 member function declared with ‘override’ does not override a base class member MyProject6 C:\Program Files\Epic Games\UE_5.4\Engine\Source\Runtime\Core\Public\Serialization\ArchiveProxy.h 167
Error (active) E0077 this declaration has no storage class or type specifier MyProject6 C:\Users\Bohlen4\Documents\Unreal Projects\MyProject6\Source\MyProject6\MyPawn.h 12
Error include found after .generated.h file - the .generated.h file should always be the last include in a header MyProject6 C:\Users\Bohlen4\Documents\Unreal Projects\MyProject6\Source\MyProject6\MyPawn.h 1
Error MSB3073 The command C:\Program Files\Epic Games\UE_5.4\Engine\Build\BatchFiles\Build.bat MyProject6Editor Win64 Development -Project=C:\Users\Bohlen4\Documents\Unreal Projects\MyProject6\MyProject6.uproject -WaitMutex -FromMsBuild -architecture=x64 exited with code 6. MyProject6 C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.MakeFile.Targets 44
(I’m a beginner so if I’m wrong please tell me)
1 Like

an “[Type] is undefined” means that you are missing a #include (in this case add " #include "TextureCompressorModule.h" " to get FTextureBuildSettings

the E1455 means that you missed something with the signature of the function marked with override copy and paste the function signature from what you are inheriting to make sure you copied it correctly

the one about #inclue found after .generated.h… this is a case of “do what it says” (you might want to try this one first as it might fix the errors above it)

the one about “exited with code 6” this means that Unreal tried, but this is Unreals “something went wrong code” (basically every exception that is thrown by the Engine is “return 6” for the “help” that gives) but it generally means something went wrong after the general C++ compiler finished for the re-assurance that gives.

1 Like

Thank you So much I got it working :>

Hi, would you be willing to share a bit more how you were able to get this working? I am having the same issue and I cannot seem to get rid of these build errors.

can you be more specific about the errors you are having, each different error type potentially has a different solution.
*things like “<type> is undefined” (might also say something about type, enum, or delegate is not declared both of these point to missing an include
*things marked override must match the base functions signature “exactly” (the only exception to this is sometimes the compiler will let you get away with the Unreal Macros not matching if you want to mark them as UFUNCTION() in a child class.
*value is never initialized before use this is supposed to be a warning, but the Unreal build tool enforces this as an Error

  • if you get an Error like C4840: non-portable use of class 'FString' as an argument... then you probably forgot “*” before a string in a UE_LOG

most other C++ errors/Warnings are more direct. some of the Unreal ones can be obtuse and remember in the IDE in either the output log, or the Error list you can double-click the error and it will jump to the line in question, and most of the error will point to the correct line (unless you failed a first pass assert but that is a different ball park)

Hi, I have the same errors, specifically:
“member function declared with ‘override’ does not override a base class member” (repeated twice).
“identifier ‘FTextureBuildSettings’ is undefined”.
Could you please clarify:

  1. I tried adding it to different files, but it only resulted in more errors. Where exactly should I add `#include “TextureCompressorModule.h”?
  2. Regarding the “member function declared with ‘override’ does not override a base class member” error: Could you provide a more detailed explanation of how to fix it?
    I’m just starting out, so I apologize if my questions seem basic or naive. Thank you!

you will typically put the include in the earliest header or implementation file that it is needed, and for the header for classes we can use forward-declarations so that we can put the actual include in the implementation file (the .cpp):
lets say I have the following header the implementations should be evident.

//MyActorComponent.h

#pragma once

#include "CoreMinimal.h"
#include "Components/ActorComponent.h"

#include  "MyActorComponent.generated.h"

USTRUCT(BlueprintType)
struct FMyActorComponentStruct
{
    GENERATED_BODY()
//...
};

UCLASS(BlueprintType, Blueprintable, meta=(BlueprintSpawnableComponent))
class MYGAME_API UMyActorComponent : public UActorComponent
{
    GENERATED_BODY()
public:
    UPROPERTY(EditAnywhere, BlueprintReadWrite)
    FMyActorComponentStruct ComponentStruct;

    UFUNCTION(BlueprintCallable)
    FMyActorComponentStruct GetComponentStruct();
//...
};

if I wanted to have another class lets say some Manager that wants had a function to receive the struct explicitly (not using the getter I created.

// MyComponentManager
#pragma once

#include "CoreMinimal.h"
#include "MyActorComponent.h" // this is needed because I want to have the struct explicitly
#include "MyComponentManager.generated.h"

UCLASS(BlueprintType, Blueprintable, meta=(BlueprintSpawnableComponent))
class MYGAME_API AMyComponentManager
{
    GENERATED_BODY()
public:
    UFUNCTION(BlueprintCallable)
    void DoWorkwithComponentStructs( FMyActorComponentStruct& componentStructs);
// ...
};

in this formulation I must include the header file that holds the struct type because under Unreal engine structs especially USTRUCT cannot be forward declared (under C++ standards forward declaring structs is allowed but should be avoided if possible)

alternatively I could have

/ MyComponentManager
#pragma once

#include "CoreMinimal.h"
#include "MyComponentManager.generated.h"

UCLASS(BlueprintType, Blueprintable, meta=(BlueprintSpawnableComponent))
class MYGAME_API AMyComponentManager
{
    GENERATED_BODY()
public:
    // because I forward declare the class and receive the pointer I do not need to include the header for the class in this header.
    UFUNCTION(BlueprintCallable)
    void DoWorkwithComponentStructs( class UMyActorComponent* componentThatHoldsStructs);
// ...
};

-keep in mind that I still need to include MyActorComponent.h in the MyComponentManager.cpp

On the matter at hand:
you will need to include the header that containing the definition of FTextureBuildSetters in the header if they are meant to be used in a function or member variable of the class if you intend to use it or have it received out right, or maybe you can have an intermediary container class to get to the given struct.

-For more details I would need to see a rough skeleton of the setup for where to include the file holding the struct

  1. for overriding a virtual function:
  • A virtual function is “typically” defined in an interface (you can technically define a virtual an any class at any point along inheritance, where it mostly signifies intent that “this shall be re-implemented in the inheriting class”
  • keyword override must be paired with keyword virtual (otherwise override is not needed, and will actually throw an error) just re-implementing a non virtual function is valid and is treated differently when the object code is generated.
  • the signature must match exactly: name, argument types and modifiers, and argument order. (the name of arguments “technically never” matters, and when separating declaration and implementation only exist in the function declaration for human readability)

Lets say I have a UMyActorComponent : public UActorComponent and then I wanted to give am implementation of PostEditChangeProperty() (so that when I change something in the editor then I can make changes to other members), and SetVisibility().

for PostEditChangeProperty():
-it must go inside a pre-processor block for #ifdef WITH_EDITOR (otherwise I will fail the cooking process)
-I need to copy the signature exactly (this is one of the few advantages that Rider has of Visual Studio, but it would be an intelli-Sense update) often I will go to the parent class by selected the inheriting the class name and right-click->Go To Definition then searching for the function name and copying that

for SetVisibility()
-I only need to copy the function signature to then be able to re-implement the function and catch calls to it.

So I would end up with

public:
#if WITH_EDITOR // #ifdef is also valid
    virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
#endif
    void SetVisibility(bool bNewVisibility, bool bPropagateToChildren=false);

I can then utilize the engines Super:: parent class resolution system to be to the next highest implementation if I do not want to just replace it outright (this is considered simultaneously a strong point and weak point of Object-Oriented-Programming based on trust of re-implantation potential