Simply put, “How Do I add an Include Path to my Project?”
I would like to add "D:\Boost\Boost_1_81_0" … and I’ve tried this using the visual studio properties (both C++ paths and nmake paths); I’ve also tried creating an empty plugin and adding to "PublicIncludePaths.Addrange( new string[] { "D:/Boost/boost_1_81_0" } ) in BoostBuild.sh (The empty plugin is called Boost).
I briefly tried sucking Boost into the plugin — but this is a waste. There is no need to “build” the code — there is some buildable code in boost, but I’m not using it. I’m looking to suck in some template code.
I tried #include "D:\Boost\boost_1_81_0\boost\spirit\include\qi.hpp" … but that was always going to fail — qi.hpp includes other things and so on.
This shouldn’t be rocket science. I get the plugin framework — so manage a dynamically loaded binary into the editor and whatnot, and to allow you to distribute it in the marketplace. I don’t see any boost plugin in the marketplace, either.
I could, of course, isolate my functions in another library or somesuch. Since I’m planning to use quite a few boost features to accelerate my development, I don’t expect that will be either good for the code or good for the project.
OK. I’m going to answer my own question. Been working on this on and off for a couple of weeks. Documentation is scarce and dense and not at all friendly.
You need to add the following to your MyModule.Build.cs file:
PublicIncludePaths.AddRange( new string[] {"D:/Boost/boost_1_81_0"});
bEnableUndefinedIdentifierWarnings = false;
… where (say) d:\Boost\boost_1_81_0 is where you unpacked Boost.
The 2nd line — about the warnings is required to make it shut up about substituting a 0 for #ifdef’s … typically placed around header files that are more portable (like boost).
With these two changes #include <boost/spirit/include/qi.hpp> works.
OK. Replying again. This is very frustrating because the configuration of the Unreal Editor an subsequently the configuration that applies to Visual Studio are complex, obtuse and often (in the programming sense) lazy. So the question is not answered.
Here’s the status … if I added the #include <boost/spirit/include/qi.hpp> to my Actor class, it complained it couldn’t load it. So I added to a module file that wasn’t being used as an Unreal class, and that worked — or seemed to work. Now that I examine things, the #include is still underlined by the automation in VS … but the fact that things compiled fooled me into thinking that I has solved things.
It was only after I made a non trivial function using boost and then make a point in my Actor class that called it … that I finally get the “cannot load file” error.
Trying to build a Python API to interact with the Unreal simulation using boost and currently facing the same issue as you. Would be great if someone could help out!
Managed to include the boost library by copying the contents from /usr/include/boost (on Linux that is) to Source/Private in the UE project. This allowed me to include the boost headers, however, on Linux this resulted in a whole bunch of other issues, but maybe it works for you. The issues on my end were related to some Visual Studio compiler macros not available in the Linux compiler.
you might need to modify the project’s build settings in the Unreal Editor. Here are the steps:
Open your Unreal project in the Unreal Editor.
Click on the “Edit” menu and select “Project Settings”.
In the left-hand sidebar, expand the “C++” section and select “Build”.
Scroll down to the “Include Directories” section and click the “+” button to add a new path.
Enter the path to your external include directory in the text box (e.g. “D:\Boost\Boost_1_81_0”) and click “Add Directory”.
Click “Apply” to save your changes.
Now Unreal build system will automatically search for header files in the specified directory when building your project. You should now be able to include headers from your external library in your project’s C++ code.
After making these changes, you should be able to include Boost headers in your C++ code using the #include