How to include the header file from a plugin

I’m sure this has been asked before but I can’t seem to find a suitable answer. I’ve read this question:

How to Include files from another module

It suggests I haven’t added the dependency into the Build.cs. However, as it is a game project rather than a plugin, it as a Target.cs file and I can’t see a way of adding the dependency.

I am trying to include a header file that is in the Classes folder of the plugin. I don’t know what the path should be, but I tried Plugins/[PluginName]/Source/[PluginName]/Classes and just the name of the file itself. In any case, it says it cannot find the file.

If I forcibly include it (by putting an explicit path to the file), then I get an error saying that the .generated file could not be found (presumably because it hasn’t compiled the plugin at this stage).

How do I configure a game project to be able to include a header file from a plugin that resides within its plugin directory?

Hi, I used to have the same problem. You’ll need to put the name of the module you’re trying to include in your modules Build.cs file. In your solution explorer, there should be a file titled You’ll see a line that looks like this:

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

Just simply add the name of the new module on the end of the line, in the same style as the rest. You’ll also need to add the path to the include files, which will require adding a new line, something like…

PublicIncludePaths.AddRange(new string[] {"<Modulename>/Public", "<Modulename>/Classes" });

Then just simply include the headers as you normally would.


This fixes the include error (as in, it can now find the relevant file). However, for some reason I am getting linker errors when using the reflection stuff (like calling StaticClass on a class from the plugin. Do you know why this could be or is it probably unrelated?

I was able to resolve this using the _API define on the class. See this question/answer:

Doing this does not fix my include error. When I put the mouse over the red squigly it says that proceduralmeshcomponent.h cannot be found. I’ve added the following to my build.cs

PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "ProceduralMeshComponent" });
        PrivateIncludePathModuleNames.AddRange(new string[] { "ProceduralMeshComponent/Runtime", "ProceduralMeshComponent/Public", "ProceduralMeshComponent/Classes", "ProceduralMeshComponent/Private" });
        PublicIncludePaths.AddRange(new string[] { "ProceduralMeshComponent/Runtime", "ProceduralMeshComponent/Public", "ProceduralMeshComponent/Classes", "ProceduralMeshComponent/Private" });

You probably better off asking a new question with more details about the specific module you are trying to compile against.

The question in this post is about plugins and the header file not reading - which is exactly what mine is about. Does it matter which plugin? The header file cannot be opened. I’ve included material I’ve discovered on this post in my Build.cs and it doesn’t appear to be resolving what it is said to resolve - You had posted earlier that it resolves the include error but then you had other issues. I’m focusing on the include issue. Mine still won’t find the ProceduralMeshComponent.h (a plugin).

I’m using the following and it was able to find proceduralmeshcomponents for the build.

    PublicIncludePaths.AddRange(new string[] {"ProceduralMeshComponent/Public", "ProceduralMeshComponent/Classes"});
    PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "RHI", "RenderCore", "ShaderCore", "ProceduralMeshComponent" });

Visual Studio did not find it for intellisense/autocomplete. To fix the include error, select MyProject->properties, ConfigurationProperties->VC++ Directories-> LibraryDirectories, and add the paths you want. For example i added:

C:\Program Files\Epic Games\4.9\Engine\Plugins\Runtime\ProceduralMeshComponent\Source\Public

It still doesn’t want to recognize the content of the file. Im still working on that.

It solves my problem. Note to add those in your not the plugin’s file.

And I was partially be able. Issue is that I search for Plugin/include and what this does is Plugin/Source/Plugin include. I tried to go up relatively, but no luck. At the end I just copy-pasted the include folder inside. Linking works, btw.

1 Like

I think you need to do a few things in order to do that, the corrosponding .cpp of the plugins header needs to have the plugins API tag so you can access it from outside the plugin, you need the full path for your include. And maybe someting in your build.cs but I don’t think so.

Why do we have to add to includes list too? Isn’t is enough to include the module like we do with the rest of the modules?

  • Open project in editor.
  • File → Refresh Visual Studio 2017 Project.
1 Like

this worked for me

thx, you saved me from a lot of headaches

Hey here is a solution if you are developing with ue5 on macos, what you need to do is to ensure the name of the Plugin is added to the AdditionalDependencies list in the .uproject file.

for example:


“Modules”: [
“Name”: “SlimeBossFight”,
“Type”: “Runtime”,
“LoadingPhase”: “Default”,
“AdditionalDependencies”: [

Note: Your plugin is going to be a module which gets included in other projects. By default, if you include your module plugin in your project, only the editor can access your classes and library functions. If you want to give your code access to your plugin classes, remember to add “_API” to your class definition. Example:

class VRTECH_API UGameLib : public UBlueprintFunctionLibrary


This grants any project using my “vrtech” module as a dependency with code access to its function library. I spent a good two hours trying to figure this out.
Note: enums don’t need the API markup.

1 Like

@newbprofi , thank you so much! It solved the issue with plugin reference I had :pray:

This is the one I was looking for, thanks a lot!