Third party library support

I have found quite the collection of libraries located in Unreal Engines Installation directory C:\Program Files (x86)\Epic Games\4.12\Engine\Source\ThirdParty. I am currently interested in using the libWebSockets library located in that directory. In that directory there contains a file named libWebSockets.Build.cs and a directory named libwebsockets. The build file is apparently used to import the library into the project, however I cannot find out how to do this other than a make your own library tutorial wiki page (the tutorial is largely unnecessary due to the install script located in the directory). Ultimately I just need to load the library. However I would prefer to link the compiler to utilize the install script located in that directory if that was it’s intended purpose. I cannot find any documentation to these libraries, only to random people claiming to use them in their projects. Mainly this thread here.

Just add libWebSockets to the PublicDependencyModuleNames of your Build.cs

PublicDependencyModuleNames.AddRange(new string[] { ... "libWebSockets" });

(Not sure if adding OpenSSL to the PublicDependencyModuleNames will also be required for SSL)

After that, I regenerated my VS Project files and included the header libwebsockets.h

The I got errors about ambiguous symbols. Surrounding the include with:

#include "AllowWindowsPlatformTypes.h"
#include "libwebsockets.h"
#include "HideWindowsPlatformTypes.h"

fixed the problem.

Hmm, I am struggling with this same issue, but including libwebsockets.h ends up including openssl, which has a collision with UI:

C2365 ‘UI’: redefinition; previous definition was ‘namespace’ SimpleNakamaExample …\UE_4.15\Engine\Source\ThirdParty\OpenSSL\1.0.2g\include\Win64\VS2015\openssl\ossl_typ.h 172

Anyone deal with that? So far, searching around I’ve found folks manually copying the openssl headers into their projects and altering them, but that seems less than optimal. :frowning:

I ran into a similar issue and in exploring the Unreal Engine code base found a couple of places where the libwebsockets.h file was imported in their code and found the approach they used, which is:

/*
ObjectBase.h (somehow included here) defines a namespace called UI,
openssl headers, included by libwebsockets define a typedef with the same names
The define will move the openssl define out of the way.
*/
#define UI UI_ST
THIRD_PARTY_INCLUDES_START
#include "libwebsockets.h"
THIRD_PARTY_INCLUDES_END
#undef UI

I found that in the \Engine\Source\Runtime\NetworkFileSystem\Private\NetworkFileServerHttp.h file. I tried this on my end and the redefinition errors went away.