How do I Create C++ Projects with UE5?

Hi everyone,

It’s now been more than 24hrs that I try to set up a C++ Project in UE5, and I’m at the end of my wits here :frowning:
Blueprint works fine at first, but the second I add a C++ file, the project will no longer open.

Is there some idiot-proof tutorial somewhere that can show me how to set this up?

I keep getting this error:

ERROR: Error while enumerating Visual Studio toolchains
COMException: Error HRESULT E_FAIL has been returned from a call to a COM component.
   at Microsoft.VisualStudio.Setup.Configuration.ISetupInstance2.GetState()

Hey @da_maury! Welcome to the Forums!

The first thing you need to do is to try reinstalling visual studios following all the steps listed here:

It is most likely that there may have been some sort of error during installation.

I hope the above solution works for you!

Hey @Quetzalcodename

thank you!

My hopes are low at this point, but I’ll give it another shot with that guide.

Will let you know how it went!

No avail :frowning:

This is with VS2022 however

Log started at 8/1/2022 12:55:44 PM (2022-08-01T10:55:44Z)
No config file at C:\Users\damaury\Documents\Unreal Engine\UnrealBuildTool\BuildConfiguration.xml
Configuration will be read from:
  C:\Users\damaury\AppData\Roaming\Unreal Engine\UnrealBuildTool\BuildConfiguration.xml
Found Windows 10 SDK root at C:\Program Files (x86)\Windows Kits\10 (1)
Found Windows 10 SDK root at C:\Program Files (x86)\Windows Kits\10 (2)
Found Windows 10 SDK version 10.0.18362.0 at C:\Program Files (x86)\Windows Kits\10
Found Universal CRT version 10.0.18362.0 at C:\Program Files (x86)\Windows Kits\10
Win64 using Manual SDK 10.0.18362.0
Log file: C:\Users\damaury\AppData\Local\UnrealBuildTool\Log_GPF.txt
Deleting old log file: C:\Users\damaury\AppData\Local\UnrealBuildTool\Log_GPF-backup-2022.07.31-08.39.13.txt


---   SDK INFO START   ---
---   SDK INFO END   ---

Discovering modules, targets and source code for project...
Skipping D:\Epic Games\UE_5.0\Engine\Intermediate\Build\BuildRules\UE5Rules.dll: File is installed
Skipping D:\Epic Games\UE_5.0\Engine\Intermediate\Build\BuildRules\UE5ProgramRules.dll: File is installed
ERROR: Error while enumerating Visual Studio toolchains
COMException: Error HRESULT E_FAIL has been returned from a call to a COM component.
   at Microsoft.VisualStudio.Setup.Configuration.ISetupInstance2.GetState()

you need 2019, not sure if it works out of the box with 2022. try first getting these packages both for windows 10 and 11

01

I didn’t update the windows SDKs, it works with those I have, but try getting the most recent ones.

If you don’t have storage space issue just get them all just to be sure

Hi @dorusoftware

I tried with VS2019, but still getting the same error :frowning:

Log started at 8/1/2022 4:45:05 PM (2022-08-01T14:45:05Z)
No config file at C:\Users\damaury\Documents\Unreal Engine\UnrealBuildTool\BuildConfiguration.xml
Configuration will be read from:
  C:\Users\damaury\AppData\Roaming\Unreal Engine\UnrealBuildTool\BuildConfiguration.xml
Found Windows 10 SDK root at C:\Program Files (x86)\Windows Kits\10 (1)
Found Windows 10 SDK root at C:\Program Files (x86)\Windows Kits\10 (2)
Found Windows 10 SDK version 10.0.18362.0 at C:\Program Files (x86)\Windows Kits\10
Found Universal CRT version 10.0.18362.0 at C:\Program Files (x86)\Windows Kits\10
Found Windows 10 SDK version 10.0.19041.0 at C:\Program Files (x86)\Windows Kits\10
Found Universal CRT version 10.0.19041.0 at C:\Program Files (x86)\Windows Kits\10
Found Windows 10 SDK version 10.0.22000.0 at C:\Program Files (x86)\Windows Kits\10
Found Universal CRT version 10.0.22000.0 at C:\Program Files (x86)\Windows Kits\10
Win64 using Manual SDK 10.0.18362.0
Log file: C:\Users\damaury\AppData\Local\UnrealBuildTool\Log_GPF.txt
Deleting old log file: C:\Users\damaury\AppData\Local\UnrealBuildTool\Log_GPF-backup-2022.07.31-08.39.13.txt


---   SDK INFO START   ---
---   SDK INFO END   ---

Discovering modules, targets and source code for project...
Skipping D:\Epic Games\UE_5.0\Engine\Intermediate\Build\BuildRules\UE5Rules.dll: File is installed
Skipping D:\Epic Games\UE_5.0\Engine\Intermediate\Build\BuildRules\UE5ProgramRules.dll: File is installed
Found Visual Studio installation: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community (Product=Microsoft.VisualStudio.Product.Community, Version=16.11.32630.194)
ERROR: Error while enumerating Visual Studio toolchains
COMException: Error HRESULT E_FAIL has been returned from a call to a COM component.
   at Microsoft.VisualStudio.Setup.Configuration.ISetupInstance2.GetState()

Did you have tried to create a C++ project directly, instead of converting a blueprint project to C++?

Yes, I have

Any other ideas I can try out?

Hey @da_maury,

I noticed you are selecting the option to install the Unreal Engine installer, however you already have Unreal installed, have you tried installing without that?

Also, do you have UE Engine Source enabled in your 5.0 options?

EpicGamesLauncher_B6NgoEJxvU

EpicGamesLauncher_VV6tQOHIfg

Hopefully the above gets you some results.

Hey @Quetzalcodename

The engine source is enabled in the 5.0 options.

On the Unreal Engine Installer:
I removed all versions of VS, and hit install VS2019 from the Unreal Engine Create C++ Project button.
The feature Unreal Engine Installer came pre-ticked, and I removed it.

Alas, the result is the same:

Log started at 8/2/2022 12:50:56 PM (2022-08-02T10:50:56Z)
No config file at C:\Users\damaury\Documents\Unreal Engine\UnrealBuildTool\BuildConfiguration.xml
Configuration will be read from:
  C:\Users\damaury\AppData\Roaming\Unreal Engine\UnrealBuildTool\BuildConfiguration.xml
Found Windows 10 SDK root at C:\Program Files (x86)\Windows Kits\10 (1)
Found Windows 10 SDK root at C:\Program Files (x86)\Windows Kits\10 (2)
Found Windows 10 SDK version 10.0.17763.0 at C:\Program Files (x86)\Windows Kits\10
Found Universal CRT version 10.0.17763.0 at C:\Program Files (x86)\Windows Kits\10
Win64 using Manual SDK 10.0.17763.0
Log file: C:\Users\damaury\AppData\Local\UnrealBuildTool\Log_GPF.txt
Deleting old log file: C:\Users\damaury\AppData\Local\UnrealBuildTool\Log_GPF-backup-2022.07.31-08.39.13.txt


---   SDK INFO START   ---
---   SDK INFO END   ---

Discovering modules, targets and source code for project...
Skipping D:\Epic Games\UE_5.0\Engine\Intermediate\Build\BuildRules\UE5Rules.dll: File is installed
Skipping D:\Epic Games\UE_5.0\Engine\Intermediate\Build\BuildRules\UE5ProgramRules.dll: File is installed
ERROR: Error while enumerating Visual Studio toolchains
COMException: Error HRESULT E_FAIL has been returned from a call to a COM component.
   at Microsoft.VisualStudio.Setup.Configuration.ISetupInstance2.GetState()

Ok, so after some digging through the UnrealBuildTool, I noticed that this for-loop here runs out of bounds.

UnrealBuildTool\Platform\Windows\UEBuildWindows.cs
Line: 1193

for (; ; )
  {
    int NumFetched;
    Enumerator.Next(1, Instances, out NumFetched);

    if (NumFetched == 0)
    {
      break;
    }

    ISetupInstance2 Instance = (ISetupInstance2)Instances[0];
    if ((Instance.GetState() & InstanceState.Local) != InstanceState.Local)
    {
      continue;
    }

    ...

I have one instance of VS installed, but it tries to run through the loop twice, and ofc crashes the second time.

OK, so I don’t know what consequences this will have down the road…

I hacked my way around the issue by recompiling the UnrealBuildEngine, breaking the loop, if an instance is already found. Seeing how I only have one instance anyway, it should be fine for me.

I feel like taking a shower now, and cowering in shame… but maybe have one of your guys have another look at it?

for (; ; )
{
    if (Installations.Count > 0) {
        break;
    }

I am quite sure UE5 requires Visual Studio 2022 with the proper components.





@L.F.A Cheers for the help!

It could be what you described…
For me, it was just that failing for-loop in the UnrealBuildEngine in UEBuildWindows.cs

I just created a C++ project. I am also able to add C++ Classes to existing projects.
I’d say: “Solved by workaround”, but I fear others will run into the same issue.
Therefore, I feel uncomfortable tagging my previous post as a “solution”.

I am rather reluctant about installing and uninstalling more packages for now though… :frowning:
Must have downloaded over 300GB worth of data in my attempts so far

It may also break in some unlikely corner in 2 days… so I really don’t feel comfortable with what I have right now either. I may feel different about it tomorrow, not sure

If you feel I should tag it as solved, I’ll do it tho

Once again, much appreciate the help guys!
@Quetzalcodename @dorusoftware @L.F.A

1 Like

Hi there, it good to know that you fixed the issue, and it is totally up to you to set as solved. Because, in my understanding, the true validation test is to package your project and see if there are any further errors or crashes.

What is important is trying to understand what was missing in the first attempt and learn from that. If you really want to understand what happened, you’d have to uninstall everything and re-do what is already done. However, this is time consuming.

You can just create a final reply to your post and list the information that you believe are correct, and that will serve as a “heads up” for the new users that might face similar problems. And keep you post unsolved for a moment.

I wish you success in you learning journey.
All the best.

1 Like