Plugin does not package, but can build and works in the editor. Why? (error C2653)

Hello :slight_smile:
I have a problem when I package one of my plugins in c++.

I can build it with Visual studio and live coding, then use my plugin without problem in editor/runtime.

But when I want to package my plugin when the module compiles, it tells me :
\Source\FileManagement\Private\FileManagementBPLibrary.cpp(27): error C2653: ‘FPlatformFileManager’: is not a class or namespace name

If I’ve understood correctly after searching on Internet, ‘FPlatformFileManager’ doesn’t seem to be included. But from what I found in the unreal doc I’ve already included it with #include “GenericPlatform/GenericPlatformFile.h” and the “Core” module is included in my plugin module as well.
(IPlatformFile | Unreal Engine 5.2 Documentation)

I’ve tried include in .cpp or .h and both at the same time, but nothing works. :smiling_face_with_tear:


I also found a topic talking about this kind of problem.
(Error C2653: is not a class or namespace name (or: non UClass class))
The problem was on UE4 in 2014 and a solution was to add this kind of line in the [project].Build.cs .
PrivateIncludePaths.Add("MyProjectFolder/Headers");

I don’t know if this is really a good way to solve this problem? If so, I didn’t quite understand where to put the line in the [project].Build.cs and the exact content, which must be between " ".

I’m rather new to C++ :sweat_smile:, so thanks for any help in advance :slight_smile:

is [include “HAL/PlatformFileManager.h”] included in the header or cpp file that is throwing a compilation error?

[project name].Build.cs for the project should be located under [root project folder]/Source/[project name]/[project name].Build.cs

[module name].Build.cs for plugins should be located under [root folder]/Plugins/[your plugin]/Source/[modu;e name]/[module name].Build.cs

About: Why?

try cleaning the solution
when this kind of problem happens I usually do git clean -fddx
but you need to have .gitignore for Unreal Engine Projects (ofc if you are using git)
you can use this one from GitHub https://github.com/github/gitignore/blob/main/UnrealEngine.gitignore

after most likely you will receive the same errors when building from VS
it’s probably happening as there is cached data somewhere that is not being rebuilt so it allows you running but as soon as it builds from scratch it fails

After further research and testing, I found a solution. In the build.cs file, I just add using System.IO; under using UnrealBuildTool; in first lines. Then I can package with IPlatformFile


Thank you Kyrylo Mishakin for taking the time to look and for responding so quickly. :+1:

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