Compile Fails, No Errors in Log

When I try to compile my code within Unreal, it fails. However, when I look in the log, it shows no cause of the failure. There are no errors whatsoever, everything is marked as info. Here are the last few lines of the log:


CompilerResultsLog: Info Reflection code generated for ColonizeEditor in 5.6058421 seconds
CompilerResultsLog: Info  @progress 'Generating code...' 67%
CompilerResultsLog: Info  @progress 'Generating code...' 100%
CompilerResultsLog: Info  @progress pop
CompilerResultsLog: Info  @progress 'Compiling C++ source files...' 0%
CompilerResultsLog: Info Performing 2 actions (12 in parallel)
CompilerResultsLog: Info  @progress 'Compiling C++ source code...' 0%
CompilerResultsLog: Info [1/2] Compile GameDirector.cpp
CompilerResultsLog: Info  @progress 'Compiling C++ source code...' 33%
CompilerResultsLog: Info  @progress 'Compiling C++ source code...' 67%
CompilerResultsLog: Info -------- End Detailed Actions Stats -----------------------------------------------------------
CompilerResultsLog: Info ERROR: UBT ERROR: Failed to produce item: /home/[username]/Documents/Unreal Projects/Colonize/Binaries/Linux/libUE4Editor-Colonize-1909.so
CompilerResultsLog: Info Total build time: 9.45 seconds
LogMainFrame: MainFrame: Module compiling took 9.735 seconds
Warning: HotReload failed, recompile failed

It announces that it has failed, but gives no reason why. I can fix this nonexistent error by commenting out a line of code in a very basic actor class. Here is the code for it:



//==========GameDirector.h==========
#pragma once

#include "GameFramework/Actor.h"
#include "Landscape.h"
#include "Materials/MaterialInstance.h"
#include "GameDirector.generated.h"

UCLASS()
class COLONIZE_API AGameDirector : public AActor
{
  GENERATED_BODY()
public:	
 UPROPERTY(EditAnywhere)
 ALandscape* terrain;
 UPROPERTY(EditAnywhere)
 UMaterialInstance* tMat;
 
 // Sets default values for this actor's properties
 AGameDirector();

 // Called when the game starts or when spawned
 virtual void BeginPlay() override;
 
 // Called every frame
 virtual void Tick( float DeltaSeconds ) override;
};

//=========GameDirector.cpp==========
#include "Colonize.h"
#include "GameDirector.h"
#include "Materials/MaterialInstance.h"


// Sets default values
AGameDirector::AGameDirector()
{
	PrimaryActorTick.bCanEverTick = true;

}

// Called when the game starts or when spawned
void AGameDirector::BeginPlay()
{
	Super::BeginPlay();
	tMat->setScalarParameterValue("GridOverlayOpacity", 1.0); //<<<< This is the line that is causing problems.  By commenting it out, it compiles just fine.
}

// Called every frame
void AGameDirector::Tick( float DeltaTime )
{
	Super::Tick( DeltaTime );

}


As you can see, it is primarily template code. By commenting out the line mentioned above, the compile will run just fine. What could be causing this problem?

P.S. I am using a Linux version of the editor compiled from GitHub. I am using the KDevelop IDE, so I cannot compile it from the IDE.

Update: the compile log shows no errors whatsoever. I tried inserting gibberish into one of the classes. The compile fails, but does not show an error regarding the gibberish code.

The first post of a user is always moderated (: That’s why you didn’t see it. I needed to approve it first.

Ah, ok. Thank you for clearing that up :slight_smile:

Welcome to the forums. :slight_smile:

While I cannot say what causes the error to not appear in the log this should fix the error itself:
The class UMaterialInstance does not have a function named setScalarParameterValue (nor SetScalarParameterValue). However there is a function named SetScalarParameterValueInternal. Alternatively UMaterialInstanceDynamic has a function named SetScalarParameterValue (which does nothing except call SetScalarParameterValueInternal). So simply changing that line to tMat->SetScalarParameterValueInternal(“GridOverlayOpacity”, 1.0); should work (assuming there are no other unlisted errors).

In addition to : Try using TEXT(“GridOverlayOpacity”), because FString uses wide char by default.

Since last time, the editor is now unable to open since the code needs to be recompiled. However, for some reason, that means it can now output compile errors to the command line. I have applied the advice of and @HungryDoodles (Thank you!) so the code snippet looks like this:


tMat->SetScalarParameterValueInternal(TEXT("GridOverlayOpacity"), 1.0f);

The error it is showing is as follows:


/home/username/Documents/Unreal Projects/Colonize/Source/Colonize/GameDirector.cpp:21:8: error: 'SetScalarParameterValueInternal' is a protected member of 'UMaterialInstance'
        tMat->SetScalarParameterValueInternal(TEXT("GridOverlayOpacity"), 1.0f);
              ^
/home/username//UnrealEngine/Engine/Source/Runtime/Engine/Classes/Materials/MaterialInstance.h:403:7: note: declared protected here
        void SetScalarParameterValueInternal(FName ParameterName, float Value);
             ^


It appears that I need to use a dynamic instance to be able to change the values during runtime.
Thank you for all your help! Any ideas on why the errors aren’t showing up inside the editor?

I’m sorry. I somehow missed both the lack of TEXT macro use and the protected keyword :(.
So casting tMat to UMaterialInstanceDynamic and then calling SetScalarParameterValue should work (this time for real :)). Or just change the type of tMat to avoid the cast and then call SetScalarParameterValue.

To clarify, the errors do not show in the editor (neither Output Log, nor Message Log and then Compiler Log within) when you hot reload (either via IDE or by pressing the compile button in the editor)?
What version of the engine are you using? Built from GitHub or installed?