VS: How to #include header from Engine/UE5 in Games/ProjectName

I need to include two header:


The above one doesnt work because i dont know where it should be located. The second one works, but i’d prefer VS to find it automatically so the interfaces probably would be found too…
I tried new generating of project files, adding “OnlineSubsystem” in ProjectName.Build.cs

, include directory of ue5’s plugin folder
grafik
and cant find any solution. In tutorials they dont have to deal with this at all and I cant find a solution to set this up properly.

Thats why I can’t get this one for example to work since it cant find the Interface header i guess:
OnlineSubsystem = IOnlineSubsystem::Get();

In your ProjectName.Build.cs you need to add one more entry: “OnlineSubsystemUtils”

The paths work:


But I which configuration am I missing in VS so i only need to write the bottom include:

instead of the whole path? I cant find a proper way to set any references from my game project to the UE5 project in my solution.

There is a file with the name “PutYourProjectNameHere.build.cs” at the root directory of your source files. Inside it there is an array of public dependency modules of Your project. You need to add the name of the modules you are using to this array. In your case it seems to be “OnlineSubsystem” and “OnlineSubsystemUtils”. After adding those two you should be able to include the header using only the name like in the picture.

Assuming you enabled the plugins, you only need to add the modules to ProjectName.Build.cs. It should look something like this:

PublicDependencyModuleNames.AddRange(new string[]
{
	"Core", 
	"CoreUObject", 
	"Engine", 
	"InputCore", 
	"OnlineSubsystem", 
	"OnlineSubsystemEOS", 
	"OnlineSubsystemEOSPlus", 
	"OnlineSubsystemSteam",
	"OnlineSubsystemUtils"
});

The formatting does not matter whether it is a one line or multiple lines, but it should work when you include the headers without the entire path.

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