Do it like this:
const UE::Online::IOnlineServicesPtr Services = UE::Online::GetServices();
and add this modules to your Build.cs
PublicDependencyModuleNames.AddRange(new string[]
{
"CoreOnline",
"OnlineServicesNull",
"OnlineServicesEOS",
"OnlineServicesInterface",
"Core",
"CoreUObject",
"Engine",
"InputCore"
});