How to include sources without PCH include

If you want to include an external library without building it with the UE build system, put it in YourProject/ThirdParty/YourLibrary and tell the build system to use it inside YourProject.build.cs:

var third_party_path = Path.GetFullPath(Path.Combine(ModuleDirectory, "../../ThirdParty/"));
var your_lib_path = Path.Combine(third_party_path, "YourLibrary");

PublicIncludePaths.Add(Path.Combine(your_lib_path, "include"));
PublicAdditionalLibraries.Add(Path.Combine(your_lib_path, "lib/YourLibrary.lib"));
PublicDelayLoadDLLs.Add(Path.Combine(your_lib_path, "bin/YourLibrary.dll"));

For this example, we assume the headers are in YourLibrary/include.
On Windows, the .dll needs to be also present in YourProjects/Binaries/Win64.

You can see an example of including the OpenCV library in a plugin I am developing.

1 Like