# How to include the header file from a plugin

**URL:** <https://forums.unrealengine.com/t/how-to-include-the-header-file-from-a-plugin/288341>\
**Category:** Plugins\
**Tags:** include, unreal-engine, Plugins, question\
**Created:** [July 16, 2014, 9:07am UTC](https://forums.unrealengine.com/t/how-to-include-the-header-file-from-a-plugin/288341 "2014-07-16T09:07:44Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_2db7ca80](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2db7ca80](https://forums.unrealengine.com/u/anonymous_user_2db7ca80)\
**Post date:** [July 16, 2014, 9:07am UTC](https://forums.unrealengine.com/t/how-to-include-the-header-file-from-a-plugin/288341/1 "2014-07-16T09:07:44Z")

</div>

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](https://answers.unrealengine.com/questions/54681/how-to-include-files-from-another-module.html)

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?

---

<div class="post-metadata">

**Author:** ![Oldfrith\_1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Oldfrith\_1](https://forums.unrealengine.com/u/Oldfrith_1)\
**Post date:** [July 24, 2014, 4:44am UTC](https://forums.unrealengine.com/t/how-to-include-the-header-file-from-a-plugin/288341/2 "2014-07-24T04:44:28Z")

</div>

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 YourGameName.build.cs. 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.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_2db7ca80](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2db7ca80](https://forums.unrealengine.com/u/anonymous_user_2db7ca80)\
**Post date:** [August 6, 2014, 1:03pm UTC](https://forums.unrealengine.com/t/how-to-include-the-header-file-from-a-plugin/288341/3 "2014-08-06T13:03:57Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_2db7ca80](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2db7ca80](https://forums.unrealengine.com/u/anonymous_user_2db7ca80)\
**Post date:** [August 11, 2014, 8:39am UTC](https://forums.unrealengine.com/t/how-to-include-the-header-file-from-a-plugin/288341/4 "2014-08-11T08:39:16Z")

</div>

I was able to resolve this using the \_API define on the class. See this question/answer: [https://answers.unrealengine.com/questions/79921/how-do-i-statically-link-a-plugin-to-my-game-code.html](https://answers.unrealengine.com/questions/79921/how-do-i-statically-link-a-plugin-to-my-game-code.html)

---

<div class="post-metadata">

**Author:** ![Thumper](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Thumper](https://forums.unrealengine.com/u/Thumper)\
**Post date:** [June 29, 2015, 4:23pm UTC](https://forums.unrealengine.com/t/how-to-include-the-header-file-from-a-plugin/288341/5 "2015-06-29T16:23:51Z")

</div>

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" });
```

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_2db7ca80](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2db7ca80](https://forums.unrealengine.com/u/anonymous_user_2db7ca80)\
**Post date:** [June 29, 2015, 5:30pm UTC](https://forums.unrealengine.com/t/how-to-include-the-header-file-from-a-plugin/288341/6 "2015-06-29T17:30:46Z")

</div>

You probably better off [asking a new question](https://answers.unrealengine.com/questions/ask.html) with more details about the specific module you are trying to compile against.

---

<div class="post-metadata">

**Author:** ![Thumper](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Thumper](https://forums.unrealengine.com/u/Thumper)\
**Post date:** [June 29, 2015, 5:42pm UTC](https://forums.unrealengine.com/t/how-to-include-the-header-file-from-a-plugin/288341/7 "2015-06-29T17:42:41Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_b4bf8ebc](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_b4bf8ebc](https://forums.unrealengine.com/u/anonymous_user_b4bf8ebc)\
**Post date:** [October 29, 2015, 9:42am UTC](https://forums.unrealengine.com/t/how-to-include-the-header-file-from-a-plugin/288341/8 "2015-10-29T09:42:21Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_b3f58d4b](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_b3f58d4b](https://forums.unrealengine.com/u/anonymous_user_b3f58d4b)\
**Post date:** [February 17, 2017, 8:36am UTC](https://forums.unrealengine.com/t/how-to-include-the-header-file-from-a-plugin/288341/9 "2017-02-17T08:36:21Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ryobg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ryobg](https://forums.unrealengine.com/u/ryobg)\
**Post date:** [February 25, 2017, 5:36am UTC](https://forums.unrealengine.com/t/how-to-include-the-header-file-from-a-plugin/288341/10 "2017-02-25T05:36:16Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_210522a1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_210522a1](https://forums.unrealengine.com/u/anonymous_user_210522a1)\
**Post date:** [May 8, 2017, 11:20am UTC](https://forums.unrealengine.com/t/how-to-include-the-header-file-from-a-plugin/288341/11 "2017-05-08T11:20:32Z")

</div>

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.

-

---

<div class="post-metadata">

**Author:** ![darkgaze](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@darkgaze](https://forums.unrealengine.com/u/darkgaze)\
**Post date:** [January 23, 2018, 2:37pm UTC](https://forums.unrealengine.com/t/how-to-include-the-header-file-from-a-plugin/288341/12 "2018-01-23T14:37:56Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![newbprofi](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@newbprofi](https://forums.unrealengine.com/u/newbprofi)\
**Post date:** [May 3, 2018, 6:09pm UTC](https://forums.unrealengine.com/t/how-to-include-the-header-file-from-a-plugin/288341/13 "2018-05-03T18:09:57Z")

</div>

- Open project in editor.
- File → Refresh Visual Studio 2017 Project.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_7d65a7ea](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_7d65a7ea](https://forums.unrealengine.com/u/anonymous_user_7d65a7ea)\
**Post date:** [June 3, 2019, 5:22pm UTC](https://forums.unrealengine.com/t/how-to-include-the-header-file-from-a-plugin/288341/14 "2019-06-03T17:22:38Z")

</div>

this worked for me

---

<div class="post-metadata">

**Author:** ![AAriyAA](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@AAriyAA](https://forums.unrealengine.com/u/AAriyAA)\
**Post date:** [October 19, 2019, 12:24pm UTC](https://forums.unrealengine.com/t/how-to-include-the-header-file-from-a-plugin/288341/15 "2019-10-19T12:24:02Z")

</div>

thx, you saved me from a lot of headaches

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_ae281ea41](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_ae281ea41](https://forums.unrealengine.com/u/anonymous_user_ae281ea41)\
**Post date:** [October 6, 2022, 2:27am UTC](https://forums.unrealengine.com/t/how-to-include-the-header-file-from-a-plugin/288341/16 "2022-10-06T02:27:30Z")

</div>

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”: [  
“Engine”,  
**“Paper2D”**  
]  
}  
],  
…

---

<div class="post-metadata">

**Author:** ![Slayemin](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Slayemin](https://forums.unrealengine.com/u/Slayemin)\
**Post date:** [November 16, 2022, 11:27am UTC](https://forums.unrealengine.com/t/how-to-include-the-header-file-from-a-plugin/288341/17 "2022-11-16T11:27:36Z")

</div>

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:

```auto
UCLASS()
class VRTECH_API UGameLib : public UBlueprintFunctionLibrary
{
	GENERATED_BODY()

public:
...
};
```

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.

---

<div class="post-metadata">

**Author:** ![Imaver](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Imaver](https://forums.unrealengine.com/u/Imaver)\
**Post date:** [November 19, 2022, 5:38am UTC](https://forums.unrealengine.com/t/how-to-include-the-header-file-from-a-plugin/288341/18 "2022-11-19T05:38:10Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Thoeme](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Thoeme](https://forums.unrealengine.com/u/Thoeme)\
**Post date:** [September 8, 2023, 12:26pm UTC](https://forums.unrealengine.com/t/how-to-include-the-header-file-from-a-plugin/288341/19 "2023-09-08T12:26:02Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Wasabi.in](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Wasabi.in](https://forums.unrealengine.com/u/Wasabi.in)\
**Post date:** [March 6, 2024, 11:26am UTC](https://forums.unrealengine.com/t/how-to-include-the-header-file-from-a-plugin/288341/20 "2024-03-06T11:26:39Z")

</div>

For those who simply want to import headers/classes from a project specific plugin, The solution provided here helped me:

> <https://stackoverflow.com/questions/62275619/how-do-i-include-plugin-source-files-in-my-custom-unreal-engine-module/62282560#62282560>

**Summary:**

1. Open the `.uplugin` file under the plugin folder and copy the module name you need from the `"Modules"` array. You can verify which module your header file belongs to if there is more than one module. By opening `Plugins/<Plugin_Name>/Source/` and searching the file name.

2. Once you have it, you have to add the module name to your PublicDependencyModuleNames Ranges and save. Rebuild Solution. If the build succeeds, and you can import the headers, great. otherwise, go to step 3.

3. Close VisualStudio. open the project folder in file explorer, Right-click `.uproject`, and Generate VS Project Files. Reopen VisualStudio.

[Next page](https://forums.unrealengine.com/t/how-to-include-the-header-file-from-a-plugin/288341.md?page=2)
