Build from source fails with errors C4834 and MSB3073

Hi everyone,

I’m trying to build the release version (5.2.1) from source in order to use a dedicated server. I carefully followed the readme on the github repository. I installed Microsoft Visual Studio 2022 (on Windows 10 64bits) with the required workloads as explained in the unreal documentation here.

I successfully run the Setup.bat and the GenerateProjectFiles.bat files, then opened UE5.sln in Visual Studio, selected Development Editor and Win64, and finally built UE5 from the solution explorer.

The build failed with this message :

F:\UE\Engine\Plugins\Runtime\Steam\SteamVR\Source\SteamVRInputDevice\Private\SteamVRInputDeviceFunctionLibrary.cpp(513): error C4834: discarding return value of function with 'nodiscard' attribute
F:\MSVS\MSBuild\Microsoft\VC\v170\Microsoft.MakeFile.Targets(44,5): error MSB3073: The command "..\..\Build\BatchFiles\Build.bat -Target="UnrealEditor Win64 Development" -Target="ShaderCompileWorker Win64 Development -Quiet" -WaitMutex -FromMsBuild" exited with code 6.

Here is the entire output after trying a new build :

Build started...
1>------ Build started: Project: EpicGames.UHT, Configuration: Development Any CPU ------
2>------ Build started: Project: UnrealBuildTool, Configuration: Development Any CPU ------
3>------ Build started: Project: UE5, Configuration: Development_Editor x64 ------
3>Using bundled DotNet SDK version: 6.0.302
3>Running UnrealBuildTool: dotnet "..\..\Engine\Binaries\DotNET\UnrealBuildTool\UnrealBuildTool.dll" -Target="UnrealEditor Win64 Development" -Target="ShaderCompileWorker Win64 Development -Quiet" -WaitMutex -FromMsBuild
3>Log file: F:\UE\Engine\Programs\UnrealBuildTool\Log.txt
3>Building UnrealEditor and ShaderCompileWorker...
3>Using Visual Studio 2022 14.37.32822 toolchain (F:\MSVS\VC\Tools\MSVC\14.37.32822) and Windows 10.0.22621.0 SDK (C:\Program Files (x86)\Windows Kits\10).
3>Determining max actions to execute in parallel (4 physical cores, 8 logical cores)
3>  Executing up to 4 processes, one per physical core
3>Building 6 actions with 4 processes...
3>[1/6] WriteMetadata UnrealEditor.version cancelled
3>[2/6] WriteMetadata UnrealEditor.target cancelled
3>[3/6] Link [x64] UnrealEditor-SteamVRInputDevice.lib cancelled
3>[4/6] Link [x64] UnrealEditor-SteamVRInputDevice.dll cancelled
3>[5/6] Link [x64] UnrealEditor-SteamVREditor.dll cancelled
3>[6/6] Compile [x64] Module.SteamVRInputDevice.cpp
3>F:\UE\Engine\Plugins\Runtime\Steam\SteamVR\Source\SteamVRInputDevice\Private\SteamVRInputDeviceFunctionLibrary.cpp(513): error C4834: discarding return value of function with 'nodiscard' attribute
3>F:\MSVS\MSBuild\Microsoft\VC\v170\Microsoft.MakeFile.Targets(44,5): error MSB3073: The command "..\..\Build\BatchFiles\Build.bat -Target="UnrealEditor Win64 Development" -Target="ShaderCompileWorker Win64 Development -Quiet" -WaitMutex -FromMsBuild" exited with code 6.
3>Done building project "UE5.vcxproj" -- FAILED.
========== Build: 2 succeeded, 1 failed, 5 up-to-date, 0 skipped ==========
========== Build started at 14:22 and took 03:09,272 minutes ==========

I saw both error codes C4834 and MSB3073, I obviously googled it and found different topic with similar issues here, here, and there.

I tried all the solutions proposed in these topics :

  • Deleting various files in Engine\Intermediate
  • Use a shorter path for the parent folder (can’t remember where I saw this solution)
  • Change quotes position in the command line that fails

None of them changed anything…

Thank you for reading this topic, I hope I’ll find a solution here.

6 Likes

I met this question too,And I fix it !
Delete it directly



5 Likes

Hi @Anonymous_c0b2ef1d8b6296d661f82020eeaf73de ,

Thank you very much for this answer, it works perfectly. I could have found this solution by myself but I didn’t want to modify any line of code for the first compilation…

I also tried to debug the function instead of commenting it. I tried to do

auto _ = GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, (TEXT("Unable to find Action [%s] for Action Set [%s]"), *ActionName.ToString(), *ActionSet.ToString()));

in order to satisfy the nodiscard attribute but auto doesn’t work here. I looked at the return type of this function and it seems to be void so I’m not sure to understand how it can have a void return type and a nodiscard attribute at the same time… Actually I can’t even find where the nodiscard attribute is.

Anyway, thank you very much for your help.

Hi @ptitbgdu80 and @Anonymous_c0b2ef1d8b6296d661f82020eeaf73de,
Removing line 513 is not really a solution to the problem.

This is a bug in the UE code on line 513.
It should probably be:

GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, FString::Printf(TEXT("Unable to find Action [%s] for Action Set [%s]"), *ActionName.ToString(), *ActionSet.ToString()));

instead of:

GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, (TEXT("Unable to find Action [%s] for Action Set [%s]"), *ActionName.ToString(), *ActionSet.ToString()));

Actually the problem is in the substring:

(TEXT("Unable to find Action [%s] for Action Set [%s]"), *ActionName.ToString(), *ActionSet.ToString())

This line is like:

const TCHAR *value = (TEXT("some value"), name1.CalculateString(), name2.CalculateString());

or

auto a = (op1(), op2(), op3());

the results of calling op1 and op2 will be ignored, but only op3() will be assigned to a.
So, if op1 or op2 has a “nodiscard” attribute, Visual Studio will generate an error/warning.
The previous version of Visual Studio did not have this behavior. New Visual Studio update - has.

The actual nodiscard attribute that can cause this error in this situation is UnrealString.h, line 324:

	/**
	 * Get pointer to the string
	 *
	 * @Return Pointer to Array of TCHAR if Num, otherwise the empty string
	 */
	UE_NODISCARD FORCEINLINE const TCHAR* operator*() const UE_LIFETIMEBOUND
	{
		return Data.Num() ? Data.GetData() : TEXT("");
	}

To sum up, the solution would be to use this line instead of line 513:

GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, FString::Printf(TEXT("Unable to find Action [%s] for Action Set [%s]"), *ActionName.ToString(), *ActionSet.ToString()));
24 Likes

Hi @alexkondratenko ,

Thank you for this detailed fix, I didn’t think that the problem could come from the function arguments… Actually we didn’t only remove line 513, but rather the entire function declaration and definition, and I wasn’t too much worried about that since this function is marked UDEPRECATED in the header file.

Maybe I (you ?) should pull this in UE5 git repository?

However, your fix is probably cleaner than the previous one. Thank you!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.