Let me start by telling you that I followed the standard procedure of adding all my headers, static libraries and runtime libraries within a thirdparty folder. I also indexed these folders in the build.cs file. As a matter of fact, the compiler recognize the header file, tries to compile it and only then fails.
To add some context I’m trying to add the swi-cpp2.h header file to unreal with all the related includes and runtime libraries. However, at compilation time, the compiler gives me a lot of syntaxt error over the swi-cpp2.h and swi-cpp2.cpp files, a few examples (sorry for the italian):
..\MyPlugin\ThirdParty\SWIProlog\headers\SWI-cpp2.h(1041): error C2334: token imprevisti prima di '{'. Il corpo apparente della funzione verrà ignorato.
..\MyPlugin\ThirdParty\SWIProlog\headers\SWI-Stream.h(70): error C2628: 'intptr_t' non può essere seguito da 'int'. Si è omesso ';'?
..\MyPlugin\ThirdParty\SWIProlog\headers\SWI-cpp2.cpp(78): error C4673: se si genera 'PlExceptionFail' il sito di rilevamento ignorerà i tipi seguenti
..\MyPlugin\ThirdParty\SWIProlog\headers\SWI-cpp2.cpp(972): error C2660: 'PlStream::Sputw': la funzione non accetta 2 argomenti
I also get some errors at the beginning of the compilation process but I think they’re unrelated, I’m going to write one of them here regardless:
..\MyPlugin\ThirdParty\SWIProlog\libslibswipl.lib' was not resolvable to a file when used in Module 'MyPlugin', assuming it is a filename and will search library paths for it. This is slow and dependency checking will not work for it. Please update reference to be fully qualified alternatively use PublicSystemLibraryPaths if you do intended to use this slow path to suppress this warning.
The compiler makes me believe that the header file and the cpp file are written badly but they work flawlessly on a vanilla c++ project (without unreal so to speak)
Here the piece of code where I include the header file:
#pragma once
#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
THIRD_PARTY_INCLUDES_START
PRAGMA_PUSH_PLATFORM_DEFAULT_PACKING
#include "Windows/WindowsHWrapper.h"
#include "Windows/AllowWindowsPlatformTypes.h"
#include "Windows/AllowWindowsPlatformAtomics.h"
#include "SWI-cpp2.h"
#include "Windows/HideWindowsPlatformAtomics.h"
#include "Windows/HideWindowsPlatformTypes.h"
PRAGMA_POP_PLATFORM_DEFAULT_PACKING
THIRD_PARTY_INCLUDES_END
#include "SWIPrologComponent.generated.h"
and here what I’ve written in the MyPlugin.build.cs file:
string ModulePath = ModuleDirectory;
string ThirdParty = Path.GetFullPath(Path.Combine(ModulePath, "../../ThirdParty/"));
string PrologCpp = Path.Combine(ThirdParty, "SWIProlog", "libs");
PublicIncludePaths.Add(Path.Combine(ThirdParty, "SWIProlog", "headers"));
bEnableUndefinedIdentifierWarnings = false;
PublicAdditionalLibraries.Add(PrologCpp + "libswipl.lib");
RuntimeDependencies.Add(Path.Combine(PrologCpp, "libswipl.dll"));
PublicDefinitions.AddRange(
new string[]
{
"IOSTREAM_REPLACES_STDIO",
"__GNUC__"
}
);
If someone had a similar problem let me know if they solved it. I’ve heard that unreal can be tedious about third-party libraries, I think it has something to do with the compiler, tell me if I’m wrong though.