Cannot include ShlObj_core not package

Good afternoon,

I got a problem trying to package a plugin with the header : “ShlObj_core.h” who let me read on AppData folder on Windows.

I got this problem first on a custom Blupint Plugin :

  1. UATHelper: Package Plugin Task (Windows): In file included from XXX\Test_Plugin\HostProject\Plugins\Test_Plugin\Intermediate\Build\HTML5\UE4\Development\Test_Plugin\Module.Test_Plugin.cpp:3:
  2. UATHelper: Package Plugin Task (Windows): XXX\Test_Plugin\HostProject\Plugins\Test_Plugin\Source\Test_Plugin\Private\Test_PluginBPLibrary.cpp(33,10): fatal error: ‘ShlObj_core.h’ file not found
  3. UATHelper: Package Plugin Task (Windows): #include “ShlObj_core.h”
  4. UATHelper: Package Plugin Task (Windows): ^~~~~~~~~~~~~~~
  5. UATHelper: Package Plugin Task (Windows): 1 error generated.
  6. UATHelper: Package Plugin Task (Windows): ERROR:root:compiler frontend failed to generate LLVM bitcode, halting
  7. UATHelper: Package Plugin Task (Windows): Total build time: 16.19 seconds (Parallel executor: 3.77 seconds)
  8. UATHelper: Package Plugin Task (Windows): Took 16.4941091s to run UnrealBuildTool.exe, ExitCode=5
  9. UATHelper: Package Plugin Task (Windows): ERROR: UnrealBuildTool failed. See log for more details. (C:\Program Files\Epic Games\UE_4.21\Engine\Programs\AutomationTool\Saved\Logs\UBT-UE4Game-HTML5-Development.txt)
  10. UATHelper: Package Plugin Task (Windows): (see C:\Program Files\Epic Games\UE_4.21\Engine\Programs\AutomationTool\Saved\Logs\Log.txt for full exception trace)
  11. UATHelper: Package Plugin Task (Windows): AutomationTool exiting with ExitCode=5 (5)
  12. UATHelper: Package Plugin Task (Windows): BUILD FAILED

On my second try i try to create a plugin with just “ShlObj_core.h” with the import lib plugin, and i got this error:

  1. UATHelper: Package Plugin Task (Windows): Building 4 actions with 8 processes…
  2. UATHelper: Package Plugin Task (Windows): [1/4] PCLaunch.rc
  3. UATHelper: Package Plugin Task (Windows): [2/4] TestIncludeLib.cpp
  4. UATHelper: Package Plugin Task (Windows): C:\Program Files\Epic Games\UE_4.21\Engine\Source\Runtime\Core\Public\Core.h(6): warning: Monolithic headers should not be used by this module. Please change it to explicitly include the headers it needs.
  5. UATHelper: Package Plugin Task (Windows): C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um\winnt.h(603): warning C4005: ‘TEXT’: macro redefinition
  6. UATHelper: Package Plugin Task (Windows): C:\Program Files\Epic Games\UE_4.21\Engine\Source\Runtime\Core\Public\HAL/Platform.h(899): note: see previous definition of ‘TEXT’
  7. UATHelper: Package Plugin Task (Windows): C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um\winioctl.h(10229): error C4668: ‘_WIN32_WINNT_WIN10_TH2’ is not defined as a preprocessor macro, replacing with ‘0’ for ‘#if/#elif
  8. UATHelper: Package Plugin Task (Windows): C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um\winioctl.h(10235): error C4668: ‘_WIN32_WINNT_WIN10_RS1’ is not defined as a preprocessor macro, replacing with ‘0’ for ‘#if/#elif
  9. UATHelper: Package Plugin Task (Windows): C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um\winioctl.h(10240): error C4668: ‘_WIN32_WINNT_WIN10_TH2’ is not defined as a preprocessor macro, replacing with ‘0’ for ‘#if/#elif
  10. UATHelper: Package Plugin Task (Windows): C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um\winioctl.h(15657): error C4668: ‘_WIN32_WINNT_WIN10_RS1’ is not defined as a preprocessor macro, replacing with ‘0’ for ‘#if/#elif
  11. UATHelper: Package Plugin Task (Windows): C:\XXX\Test_ImportLib\TestIncludeLib\TestIncludeLib\HostProject\Plugins\TestIncludeLib\Source\TestIncludeLib\Private\TestIncludeLib.cpp(29): warning C4005: ‘SSF_SHOWALLOBJECTS’: macro redefinition
  12. UATHelper: Package Plugin Task (Windows): C:/Program Files (x86)/Windows Kits/10/Include/10.0.18362.0/um/ShlObj_core.h(3356): note: see previous definition of ‘SSF_SHOWALLOBJECTS’
  13. UATHelper: Package Plugin Task (Windows): ERROR: UBT ERROR: Failed to produce item: C:\XXX\Test_ImportLib\TestIncludeLib\TestIncludeLib\HostProject\Plugins\TestIncludeLib\Binaries\Win64\UE4Editor-TestIncludeLib.pdb
  14. UATHelper: Package Plugin Task (Windows): (see C:\Program Files\Epic Games\UE_4.21\Engine\Programs\AutomationTool\Saved\Logs\UBT-UE4Editor-Win64-Development.txt for full exception trace)
  15. UATHelper: Package Plugin Task (Windows): Total build time: 9.64 seconds (Parallel executor: 0.00 seconds)
  16. UATHelper: Package Plugin Task (Windows): Took 10.0802356s to run UnrealBuildTool.exe, ExitCode=5
  17. UATHelper: Package Plugin Task (Windows): ERROR: UnrealBuildTool failed. See log for more details. (C:\Program Files\Epic Games\UE_4.21\Engine\Programs\AutomationTool\Saved\Logs\UBT-UE4Editor-Win64-Development.txt)
  18. UATHelper: Package Plugin Task (Windows): (see C:\Program Files\Epic Games\UE_4.21\Engine\Programs\AutomationTool\Saved\Logs\Log.txt for full exception trace)
  19. UATHelper: Package Plugin Task (Windows): AutomationTool exiting with ExitCode=5 (5)
  20. UATHelper: Package Plugin Task (Windows): BUILD FAILED

Here my code :
#include “ShlObj_core.h”
#include
#include
//#include
//#include
//#include
//#include
//#include
#include
#include
using std::string;
#include
using std::cout;
using std::cerr;
using std::endl;
#include

#define SSF_SHOWALLOBJECTS

//Local method : Convert TCHAR to string
std::string TcharsToString(TCHAR const * scz)
{
#ifdef UNICODE
std::ostringstream ossA;
ossA << scz;
return ossA.str();
#else
return scz;
#endif
}

void FTestIncludeLibModule::StartupModule()
{
//Test lib
TCHAR szAppData[MAX_PATH];
HRESULT hr = SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, 0, szAppData);

cout << "Get Application Data" << endl;
string path = "";
TCHAR szPath[MAX_PATH];
if (SUCCEEDED(SHGetFolderPath(NULL,
	CSIDL_APPDATA,
	NULL,
	0,
	szPath)))
{
	path = TcharsToString(szPath);
}

}