Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

How to include sources without PCH include

All source files in module "XXX" must include the same precompiled header first.

What is the best way to include the sources of an external library without going through all files and add the PCH include? I don't want to modify my libs just for the Unreal build system.

Product Version: Not Selected
more ▼

asked May 03 '16 at 09:08 AM in C++ Programming

avatar image

251 13 22 41

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

So I looked again at the example Adynathos gave. (thanks) And it turned out, the best way is to link a static library to my plugin and build the library outside of the UBS. For reference: Put the following block into your public MyPlugin(TargetInfo Target) section.

        new string[]

The PublicAdditionalLibraries is not included in the plugin templates, I recommend to add it - Unreal can you hear me? Thanks everybody for helping me.

more ▼

answered May 16 '16 at 09:56 PM

avatar image

251 13 22 41

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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.

more ▼

answered May 03 '16 at 01:50 PM

avatar image

206 5 8 17

avatar image rotwang May 10 '16 at 07:34 AM

Thank you,

so the trick is to move it outside the Source folder, for example we could put ThirdParty on the same level as Source:

                 new string[] {

Unfortunatly, this only works when including headers. You can't add source files to compile this way, because the build system will remove the folder from the project as soon as you call "Generate XCode project".

avatar image Adynathos May 10 '16 at 08:24 AM

Path.Combine(ModuleDirectory, "../../ThirdParty/glm")

Yes, Unreal build system does not build the ThirdParty libraries, as it is usually intended to build them outside, or download a built package, and include the shared libraries.

Alternatively, you could do something like that: MyLibrary.cpp

 #include "MyLibraryHeader.h"
 #include "MyProject.h" // the required precompiled header
 #include "MyLibraryCode_1.cpp"
 #include "MyLibraryCode_2.cpp"

avatar image Koderz May 10 '16 at 08:18 AM

The XCode project is only there to power XCode as far as I know. The Unreal Build Tool doesn't use it for compilation. It instead only uses the directory structure and the Build.cs files.

avatar image rotwang May 16 '16 at 09:05 PM

Yes, I see, I'm building my static library outside, that's fine. But I can't find a way to tell the Unreal Build System (UBS) to link it.

If I put the path into PrivateDependencyModuleNames.AddRange, UBS is eager to build it and asks me for a module files. ;) ERROR: Couldn't find module rules file for module '../ThirdParty/HelloWorld/lib/libhelloworld'

avatar image Adynathos May 16 '16 at 10:40 PM

Use PublicAdditionalLibraries for static libraries ( .lib , .a) and PublicDelayLoadDLLs for dynamic libraries ( .dll , .so). PrivateDependencyModuleNames is for Unreal modules.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question