x

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"

Adding a Third Party Library with source files

Hi,

I am trying to add a third party library that contains required header and source files. So far, I have tried adding them to a plugin and to Engine's third party folder (following this link), but both result in an identical issue.

In one of the header files, it contains

 #include <FOLDER-NAME/header-name.h>

and to include these header files, I have to add them in Visual Studio through project properties > VC++ Directories > Include Directories > add in direct path to include folder. This method will ensure that I have the required folders included without changing the files in the provided library (it is not my library, so I can't be sure when it will be updated). Should I generate visual studio project files through my project's .uproject file, these includes that I add will go missing. I believe I should be adding these through a module's build.cs, but apart from the following,

 AddThirdPartyPrivateStaticDependencies
 PublicIncludePaths
 PrivateIncludePaths

I can't seem to find another method that might include the .h files. I think changing the #include to use "" instead of <> might help, but apart from that, are there any other methods I can solve this issue?

Product Version: UE 4.16
Tags:
more ▼

asked Jun 27 '17 at 10:25 AM in Using UE4

avatar image

WeiLiang
16 1 4 13

avatar image speedpacer Jul 20 '17 at 11:27 PM

I'm having the same problem. I've gone through every tutorial, looked at examples on github, and even tried hard-coding the paths but no third party libraries are working for me. I can get VS to recognize them, no problem. But when I try to add them to the Build.cs file, I either get errors that the files can't be found or that there is something wrong with the files, like a missing comma, or "::"... been fighting with it for two days now. crazy.

avatar image speedpacer Jul 24 '17 at 01:24 PM

Okay, I figured it out, at least at the project level. I was making it harder than it needed to be as usual. Here's what I did to get it working.

  1. Created a ThirdParty path in my project's root folder

  2. Created subfolders under the ThirdParty folder for my library, such as:

    D:/UnrealProjects/MyProject/ThirdParty/MyLibrary/include D:/UnrealProjects/MyProject/ThirdParty/MyLibrary/lib/x64

  3. Copied the header files from the library into the include folder, like so:

    D:/UnrealProjects/MyProject/ThirdParty/MyLibrary/include/Mylibrary/*.h

NOTE: the library and the project have to be compiled with the same version of VS or whatever compiler you're using.

  1. Add the .lib and .dll files, etc. to the lib/x64 folder. Also add the .dll files to the MyProject/Binaries/Win64 folder.

  2. In your Build.cs file, add the following lines to point to your newly created header and library files (note you're including the path for headers files and for libraries, it's the libraries themselves):

    PublicIncludePaths.Add("D:/UnrealProjects/MyProject/ThirdParty/MyLibrary/include"); PublicAdditionalLibraries.Add("D:/UnrealProjects/MyProject/ThirdParty/MyLibrary/lib/x64/MyLibrary.lib");

  3. Close VS and right-click on the UE .uproject file and click Generate Visual Studio Project files.

  4. Now you should be add open it back up and add your #include "MyLibrary/myheader.h", and so on and everything should work. You shouldn't have to modify the VS project settings.

I was trying to go through some tutorials that suggested some fancy directory tricks to find the relative path, which is obviously something you eventually want to do, but first you want to make sure you can get the libraries added to your project and compile everything and verify it all works. Being unfamiliar with C#, I think that's where I was having trouble.

avatar image overreal Aug 07 '17 at 09:24 AM

Hi speedpacer, have you figured it out properly? Your solution is still to prebuild to use a static lib, I would like to include the source directly in the project.

avatar image speedpacer Aug 08 '17 at 03:31 PM

Sorry, overreal, I haven't had to go down that path.

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

0 answers: sort voted first
Be the first one to answer this question
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