UE 5.4 compile error Catch2

I created a new project with Blueprint and no content, then I created an empty C++ class, then complied, and got an error
File
\UE_5.4\Engine\Source\Developer\LowLevelTestsRunner\LowLevelTestsRunner.Build.cs
Line
Path.Combine(Target.UEThirdPartySourceDirectory, “Catch2”, Catch2.Version, “src”)

Catch2 has no reference.

I am using VS 2022.

Looking at file
\UE_5.4\Engine\Source\ThirdParty\Catch2\Catch2_v3.4.0.tps
and
\UE_5.4\Engine\Source\ThirdParty\Catch2\Catch2.tps

I went back to how UE5.3 worked and changed it to version 3.4

Path.Combine(Target.UEThirdPartySourceDirectory, “Catch2”, “v3.4.0”, “src”)

The project will now compile without errors.

This is a C# code issue, but only one you will get if you try to add a C++ class and recompile.

I have no idea if I should use v3.4, but this change to calling Check2 is new to 5.4.

Catch2 is part of the Test Framework, and I thought it was C++, but this error is because Catch2 is not referenced in the C# file, and calling Catch2 to get its version number is a good solution, it would require a reference to use it, so this looks like a bug, but this is a preview, so I am wondering if anyone else had this issue. I searched for this issue, but did not find it.

I did not want to report a but unless I know there is one, this appears to be a new feature someone was implementing, but I am not sure how they got it to work.

Can someone with 5.4 installed test this by creating a blank project and adding an empty C++ project, and then recompile the project using VS 2020 Community, because that is the version we should be using in 5.4, from what I have read.

I did not make any custom installations or change any settings in VS, other than those recommended by UE, so I have C++ for Unreal installed, as well as C++, and C#, which seemed to be the only ones I needed to add.

I have never tried to call a C++ function from a C# program, I normally keep them separate. Assuming Catch2 has no C# version, because that would be confusing, so calling Catch2 in C# to get its version is new to me, so I am missing something here.

I assume they are using this GitHub version

I see that version 3 has been released, and that made me think this is a new release feature, in which case I have no idea how they meant to implement it.

I am only posting the way I fixed this, and this is only for the project, this is part of the Engine that gets installed into the project, so I have no idea what version it should be, because that depends on the version you have installed.

It would be easier to read the xml file, and just add a version

\UE_5.4\Engine\Source\ThirdParty\Catch2\Catch2_v3.4.0.tps
and
\UE_5.4\Engine\Source\ThirdParty\Catch2\Catch2.tps

  <Name>Catch2</Name>
  <Version>v3.4.0</Version>

This would be easy for C# to parse and get the correct version, according to this tps file.

This is an auto-generated code and I am willing to bet it has been fixed upstream and have no idea how it shipped in this state, someone started something, but did not finish it, yet we still have to use this version of the release right now.

7 Likes

I am in the process of porting my code plugins from 5.3 to 5.4 and also have this error. Here are the logs.

2>C:\Unreal Engine\UE_5.4\Engine\Source\Developer\LowLevelTestsRunner\LowLevelTestsRunner.Build.cs(19,65,19,71): error CS0103: The name 'Catch2' does not exist in the current context
2>Done building project "UE5Rules.csproj" -- FAILED.
4>------ Build started: Project: UE5ProgramRules, Configuration: Development Any CPU ------
4>CSC : error CS0006: Metadata file 'C:\Unreal Engine\UE_5.4\Engine\Intermediate\Build\BuildRulesProjects\UE5Rules\bin\Development\ref\UE5Rules.dll' could not be found
4>Done building project "UE5ProgramRules.csproj" -- FAILED.
5>------ Build started: Project: BasicCode54ModuleRules, Configuration: Development Any CPU ------
5>CSC : error CS0006: Metadata file 'C:\Unreal Engine\UE_5.4\Engine\Intermediate\Build\BuildRulesProjects\UE5ProgramRules\bin\Development\ref\UE5ProgramRules.dll' could not be found
5>CSC : error CS0006: Metadata file 'C:\Unreal Engine\UE_5.4\Engine\Intermediate\Build\BuildRulesProjects\UE5Rules\bin\Development\ref\UE5Rules.dll' could not be found
5>Done building project "BasicCode54ModuleRules.csproj" -- FAILED.
type or paste code here
1 Like

I’ve tried building 5.4 from source, but it does not support TOptional as UPROPERTY. Is there a way to fix this in the release preview?

For whoever runs into this as it is the only result on Google.
You can go into the file that is causing the error, remove “Catch2.version” and replace it with “v3.4.0”.
Although be warned, there are a lot of breaking changes, so whatever you’re recompiling probably needs to be updated as well.

4 Likes

I’m getting this with completely new 5.4 projects, created from the third person template, along with a plethora of C++ errors.

2 Likes

Try building 5.4 from source. It doesn’t have the Catch2 error. But it is missing some features like TOptional as UPROPERTY.

The release version of 5.4 also has this issue. I don’t know how tf they could have missed this.

3 Likes


I replaced the “Catch2.version” for “v.3.4.0” and now it’s working, I only had to compile three times, but for now it’s okay

3 Likes

I got this same Catch2 error while trying to move a 5.3 project to 5.4. The project was failing to compile and upon attempting to build in VS 2022, it failed with this error among others.

In case anyone is encountering this error in a similar context, this was the fix:

Open the .sln file, find MyProjectEditor.Target.cs, and make sure DefaultBuildSettings is in there and that it’s set to .Latest (DefaultBuildSettings = BuildSettingsVersion.Latest;). In my case this was completely missing, but in some others I’ve seen, it was set to .V2 or the like, which was also causing issues.

After that, try to build your project again (don’t build the solution, just the project!), and it should successfully build, and allow you to open up the project in UE 5.4.

2 Likes

This works for me as well, thanks!

This looked like a cleaner solution but unfortunately it didn’t work. I was still getting Catch2 those errors (almost Catch22 :smiley: ) after this change.

Unfortunately I’m having the same problem with a fresh project (UE5.4)

2 Likes

Same for me, blank project c++ created on UE5.4

Hey folks - we’ve addressed this issue with a QFE, Current Available Quick-Fix Solutions.

Depending on your platform, try these steps:

Thanks for reporting!

7 Likes

This does not seem to fix the issue, still getting “LowLevelTestsRunner.Build.cs(19,65): Error CS0103 : The name 'Catch2' does not exist in the current context” error as usual.

If the issue persists, regenerating the project (Visual Studio, XCode etc) will ensure the third party files are properly included.

For Windows:
Open Powershell and navigate to the root directory of your Unreal Engine 5.4 installation - typically “C:\Program Files\Epic Games\UE_5.4” - and execute the following command using the project file absolute path:

.\Engine\Build\BatchFiles\Build.bat -ProjectFiles -project=“Absolute_Path_To_Project\Project_File.uproject” -game -engine

For Mac:
Open Terminal and use ./Engine/Build/BatchFiles/Mac/Build.sh instead, the rest of the command is similar, just make sure that the path to the .uproject file is absolute.

For Linux:
Similar with Mac but using ./Engine/Build/BatchFiles/Linux/Build.sh instead.

6 Likes

Thanks for the quick fix! I haven’t installed a QFE before, so have a few questions.

  • In windows, does the QFE do anything else other than add the missing files in Engine/Source/ThirdParty/Catch2/?
  • Is the installer uninstallable or does it just unpack a zip into the location? If so, how do I remove the QFE if I need to for whatever reason.
1 Like

Nope, it just adds the files. And since it’s not an installer, there aren’t means to uninstall it.

1 Like

have you tried searching for Catch2.Version and replacing it with “3.4.0”?

The fix worked for me migrating my project from 5.3 to 5.4. Thanks!

1 Like