Why "PublicIncludePaths.AddRange" doesn't work in Plugin?

I add head file folder “include” in my main module folder and then add "PublicIncludePaths.AddRange(new string] {“XXXX/include”);in the XXXX.build.cs. It works fine. Everything works and compiles successfully. But if I create a blank Plugin and put my head file folder “include” in the plugin module file and add the same code in the plugin.build.cs file. It won’t work, compiles with error and tells me can’t open the file, That’s why? I do the exactly same as in the main module but why won’t work in a plugin?? Urgent please help !!!

Hi there. I’m building a plugin right now.

You have to add “PluginNameFolder/Public” to that list.
In fact, the plugin must have several folders in the source folder. At least one, for the main module. I have two in mine, for example. Each of them contains the build.cs file.

Remember that you can’t use anything from the Private folder in the Public. So if you create something to be public in your plugin, then everything it includes should be public too.

Cheers

I just saw you added pluginName/ to it…

PublicIncludePaths.AddRange(
new string] {
“Myplugin/Public”
// … add public include paths required here …
}
);

Here’s what I have in case it’s useful.

Hi, thank your for replying. Actually, I wanna build a plugin with our company sdk whick including two folders(file headers and lib). I add those two folders paral with the “public” and “private” folder under the module name folder. And add “PluginNameFolder/mysdkfolder” in build.cs file. But It won’t work, when compiling it come up with errors like “xxx can be open”. Then I put “mysdkfolder” under “PluginNameFolder/Public” and compiles with error “cl : Command line error D8049: cl : Command line error D8049 : cannot execute ‘C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\bin\HostX64\x64\c1xx.dll’: command line is too long to fit in debug recordcannot execute ‘C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\bin\HostX64\x64\c1xx.dll’: command line is too long to fit in debug record”
which is so weird I’ve never encounter such compile errors before and I really don’t how to solve it… And my sdk is actually ok if I put them under a main game module like “module/mysdkfolder” and add it to public dependency in build.cs file. But in a plugin, there is so much weird problems… I really don’t know how to deal with it

I have no idea… but remember that if you add a folder that is not supposed to be a “typical” folder in your plugin, you have to use a filter file to skip those. In fact, anything you use that is not part of your plugin should go to ThirdParty folder under Source/ . Find about it in the documentation.

OK, I understand. Thank you very much :):):slight_smile:

Just hit the same issue. The following should work, from both plugin and regular modules:



// At top of .Build.cs file
using System.IO;
//
...
PublicIncludePaths.Add(Path.Combine(ModuleDirectory, "path/relative/to/module"));


3 Likes

Thank you so much !

This works fine when you are compiling the plugin within the project, but it does not when you package it for distributon.

I just went over all my includes and prefixed the include with the relative path, in .h & .cpp