# Including prolog c++ libraries inside Unreal Engine

**URL:** <https://swi-prolog.discourse.group/t/including-prolog-c-libraries-inside-unreal-engine/7562>\
**Category:** Help!\
**Tags:** bug, discussion, how-to, software\
**Created:** [July 2, 2024, 12:33pm UTC](https://swi-prolog.discourse.group/t/including-prolog-c-libraries-inside-unreal-engine/7562 "2024-07-02T12:33:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lorenzo](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/lorenzo/32/6320_2.png) [@Lorenzo](https://swi-prolog.discourse.group/u/Lorenzo)\
**Post date:** [July 2, 2024, 12:33pm UTC](https://swi-prolog.discourse.group/t/including-prolog-c-libraries-inside-unreal-engine/7562/1 "2024-07-02T12:33:07Z")

</div>

I’m using: SWI-Prolog version 9.2.4, Unreal Engine version 5.3, Visual Studio 2022 version 17.10.3

I want to add the prolog c++ SWI-cpp2.h header file to an Unreal Engine component

But when I try to do that I get compiling issues

My code looks like this:

```prolog
#pragma warning(disable: 4800)
#include "Windows/MinWindows.h"
#include "Windows/AllowWindowsPlatformTypes.h"
THIRD_PARTY_INCLUDES_START
#include "SWI-cpp2.h"
THIRD_PARTY_INCLUDES_END
#include "Windows/HideWindowsPlatformTypes.h"
#include "SWIPrologComponent.generated.h"

```

I also tried, hoping to solve anything, this:

```prolog
#pragma warning(disable: 4800)
#include "Windows/MinWindows.h"
#include "Windows/AllowWindowsPlatformTypes.h"
THIRD_PARTY_INCLUDES_START
#include "SWI-Stream.h"
#include "SWI-Prolog.h"
#include "SWI-cpp2.h"
THIRD_PARTY_INCLUDES_END
#include "Windows/HideWindowsPlatformTypes.h"
#include "SWIPrologComponent.generated.h"

```

my errors look like this:

```prolog
\ThirdParty\SWIProlog\headers\SWI-Stream.h(70): error C2628: 'intptr_t' followed by 'int' is illegal. Did you forget a ';'?
...
\ThirdParty\SWIProlog\headers\SWI-cpp2.h(1042): error C2059: syntax error: '{'
...
\ThirdParty\SWIProlog\headers\SWI-cpp2.cpp(972): error C2660: 'PlStream::Sputw': function does not take 2 arguments
...

```

and many other similar errors that shouldn’t be there of course.  
I understand this may not be the right place to discuss something like this, but if you can help me out understand the dynamics in order to compile these header files I might be able to research it on some unreal engine related discussion groups.

---

<div class="post-metadata">

**Author:** ![Lorenzo](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/lorenzo/32/6320_2.png) [@Lorenzo](https://swi-prolog.discourse.group/u/Lorenzo)\
**Post date:** [July 2, 2024, 1:36pm UTC](https://swi-prolog.discourse.group/t/including-prolog-c-libraries-inside-unreal-engine/7562/2 "2024-07-02T13:36:17Z")

</div>

I solved my issue by adding `PublicDefinitions.Add("_SWI_CPP2_H");` inside the build.cs file of the unreal project. Still I don’t understand the implications of such a mistake.

---

<div class="post-metadata">

**Author:** ![peter.ludemann](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/peter.ludemann/32/48_2.png) [@peter.ludemann](https://swi-prolog.discourse.group/u/peter.ludemann)\
**Post date:** [July 2, 2024, 1:53pm UTC](https://swi-prolog.discourse.group/t/including-prolog-c-libraries-inside-unreal-engine/7562/3 "2024-07-02T13:53:32Z")

</div>

Another thing that can cause a problem is the version of C++ that the compiler supports.  
I recently added some features to SWI-cpp2.h (which should be in the next development release), and got strange error messages from one package, until I specified `-std=c++17` (or `set(CMAKE_CXX_STANDARD 17)`).
