How to make MSVS look up the correct include paths?

I posted about my problem allready here some days ago: How to implement FSockets in 4.10? - Programming & Scripting - Unreal Engine Forums

But since it got no reactions what I’m assuming might be to the specific problem, I tryed to break it down and ask about a more generell problem what might solve my problem aswell.

So, when I was trying to implement FSockets, I encountered MSVS not able to find the includefiles unless I typed the absolute path.

Like:

#include "Runtime/Networking/Public/Interfaces/IPv4/IPv4Address.h"
#include "Runtime/Sockets/Public/SocketSubsystem.h"
#include "Runtime/Core/Public/Templates/SharedPointer.h"

instead of

#include "IPv4Address.h"
#include "SocketSubsystem.h"
#include "SharedPointer.h"

This is a problem, because the Unreal headerfiles are written in the latter styl, so I had to rewrite all of them recursively from the latter into the former. I don’t think thats the intended solution.

So how to configure MSVS to behave like expected?

Note:
I fresh set up this machine days ago, so I installed MSVS after I had allready done some work in the engine.
Might it be this produced a missconfiguration? (I’m assuming that this is something that should be usually be configured automatically, shouldn’t it?)

This is what my build.cs actually looks like:

// Fill out your copyright notice in the Description page of Project Settings.

using UnrealBuildTool;

public class GOnline : ModuleRules
{
	public GOnline(TargetInfo Target)
	{
		PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "Networking", "Sockets"});

		PrivateDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "Networking", "Sockets" });

		// Uncomment if you are using Slate UI
		// PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });
		
		// Uncomment if you are using online features
		// PrivateDependencyModuleNames.Add("OnlineSubsystem");
		// if ((Target.Platform == UnrealTargetPlatform.Win32) || (Target.Platform == UnrealTargetPlatform.Win64))
		// {
		//		if (UEBuildConfiguration.bCompileSteamOSS == true)
		//		{
		//			DynamicallyLoadedModuleNames.Add("OnlineSubsystemSteam");
		//		}
		// }
	}
}

I’m also someone who prefers reading the manual. The Build.cs contains this modules. And I also wasn’t able to find anything in the docs, what I didn’t considered what might be causing this. But the MACRO thing I’ll have a look at.

Look in your Build.cs make sure you have this two in there

PrivateDependencyModuleNames.AddRange(
     new string[] {
         ... default stuff ... add the next ones too
         "Networking",
         "Sockets",
     }
 );

If you unsure what Module to include you can lookup the Docs at the very buttom it shows you in what Module this class is located. Or you can navigate to the source file and find the Module cpp file you can find there a Macro that looks like this
IMPLEMENT_MODULE( FSocketSubsystemModule, Sockets );
In this case “Socket” is the Module name. I preffer the Docs less Headache ^^

Edit: Ohh and the Fullpath Runtime/–Modulename—/etc/etc.h (look at it as indicator I think its not always correct)

You dont need to care about the MACRO unless you do a Plugin.

Does it matter if the structure is Private or PublicDependency? because mine is public, but by default their was jsut that one.

Ok, I checked out what you wrote sofar. Sadly this is allready considered in my configs when this problem occurs.

Also, if this might indicate any usefull informations: The errors I get are: "cannot open source file “Sockets.h” " when trying to do it right. I’ll edit a full copy of my current build.cs into my OP now. maybe there is a error to be found.

Just tried on a fresh Project. Steps I done:
Add Depedencies “Networking” “Sockets” works with Public or Private does not matter
I used ProjectCharacter for testing
#include “Networking.h” in the Header
Add a FSocket* member in the header just for testing

here some random lines that makes no sense but get recognized correctly in the Characters Constructor

Socket = ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM)->CreateSocket(NAME_Stream, TEXT("default"), false);
	FString asd("something");
	FSocket* SomeOtherSocket = FTcpSocketBuilder(*asd)
		.AsReusable()
		.Listening(8);
	FIPv4Address ip;
	FIPv4Address::Parse(TEXT("127.0.0.1"), ip);
	TSharedRef< FInternetAddr > addr = ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM)->CreateInternetAddr();

Everything compiles fine and does not crash at runtime. I only using the #include “Networking.h” in the header
thats it nothing else works out of the Box

I created it as a clean class, not character. but I’ll try to follow your steps when I’m back at home tomorrow. WHen it works for me that would be great, And if not, I’ll jsut reinstall the engine + MSVS and see if it behaves diferent. And after that, I’ll see further

Did you regenerate the project files after adding the modules in the Build.cs? That fixed it for me.