Hi guys,
Today i was looking in the forum to see if anyone had this problem.
I added a package from NuGet in my Shared, UE4 Project
and did the includes…
Example:
#include <boost/bind.hpp>
Okay my lib project is Okay with compiling and everything no error, generated the lib.
Now i tried to add as Reference this new “library project”
When i Extends the class and include like that:
#include <ExternalLib/TheClass.h>
class DerivedClass : public TheClass {
//Stuff here
};
the compiler says:
'boost/bind.hpp': No such file or directory
This is caused the “boost” isn’t added
Question: I need do one more step after Install via “NuGet Package” to make it working with UE?
Anyone had a similar problem with?
Hi, have you found a solution?
Hi, yes…
The solution i’ve applied is:
1 - Create a dir inside “Source” called “ThirdDeps”
2 - Create a file named “ThirdPartyDeps.Build.cs” inside the dir.
This is the content of the file, now i dont use anymore, so maybe is outdated.
using System.IO;
using UnrealBuildTool;
public class ThirdPartyDeps : ModuleRules
{
string GetPlatformString ()
{
return (Target.Platform == UnrealTargetPlatform.Win64) ? "x64" : "x32";
}
string GetRootPath()
{
return Path.GetFullPath(Path.Combine(ModuleDirectory, "../../"));
}
private void LoadBoost()
{
const string LibraryPath = "../packages/boost.1.71.0.0/lib/native/include";//Theoretically "NuGet packages" are inside 'packages' dir
PublicIncludePaths.Add(LibraryPath);
if ((Target.Platform == UnrealTargetPlatform.Win64) || (Target.Platform == UnrealTargetPlatform.Win32))
{
string PlatformString = GetPlatformString();
string PackagesDir = GetRootPath() + "packages";
string boostVersionInDir = "1_71";
string visualStudioCompiler = "vc142";
foreach (var d in System.IO.Directory.GetDirectories(PackagesDir))
{
var dirName = new System.IO.DirectoryInfo(d).Name;
if (dirName == "boost.1.71.0.0")
{
continue;
}
string] splittedString = dirName.Split('-');
PublicAdditionalLibraries.Add(System.IO.Path.Combine(PackagesDir, dirName + "/lib/native", "lib" + splittedString[0] + "-" + visualStudioCompiler + "-mt-" + PlatformString + "-" + boostVersionInDir + ".lib"));
PublicAdditionalLibraries.Add(System.IO.Path.Combine(PackagesDir, dirName + "/lib/native", "lib" + splittedString[0] + "-" + visualStudioCompiler + "-mt-gd-" + PlatformString + "-" + boostVersionInDir + ".lib"));
// PublicAdditionalLibraries.Add(System.IO.Path.Combine(PackagesDir, dirName + "/lib/native", "lib" + splittedString[0] + "-" + visualStudioCompiler + "-mt-sgd-" + PlatformString + "-" + boostVersionInDir + ".lib"));
// PublicAdditionalLibraries.Add(System.IO.Path.Combine(PackagesDir, dirName + "/lib/native", "lib" + splittedString[0] + "-" + visualStudioCompiler + "-mt-s-" + PlatformString + "-" + boostVersionInDir + ".lib"));
}
PublicDefinitions.Add(string.Format("WITH_BOOST_BINDING={0}", 1));
}
}
private void LoadNetworkLib()
{
string LibraryPath = "../Source/NetworkLib";
PublicIncludePaths.Add(LibraryPath);
if ((Target.Platform == UnrealTargetPlatform.Win64) || (Target.Platform == UnrealTargetPlatform.Win32))
{
string PlatformString = GetPlatformString();
string fullPlatformPath = GetRootPath() + GetPlatformString();
string buildType = "Debug";
if(System.IO.Directory.Exists(fullPlatformPath + "/Release") == true)
{
buildType = "Release";
}
PublicAdditionalLibraries.Add(System.IO.Path.Combine(fullPlatformPath, buildType+"/NetworkLib.lib"));
}
}
public ThirdPartyDeps(ReadOnlyTargetRules Target) : base(Target)
{
Type = ModuleType.External;
}
}
3 - After you go inside your “MyProject” dir(located inside “Source”)
4 - Add the index “ThirdPartyDeps” in your “MyProject.Build.cs” close to this line:
PublicDependencyModuleNames.AddRange(new string] { "Core", "CoreUObject", "Engine", "InputCore", "Http", "Json", "JsonUtilities", "ThirdPartyDeps" });
Hope it helps! 