How to import other c++ library to UE5 like CGAL?

Hi Guys,

I have read a lot of blogs about importing third party libraries, unfortunately none of them are easy and convenient like Python.

May I know why and the easies way to do it?

The reason why I need import CGAL is because I need do some polygon’s calculations such as union, intersection and difference in UE(2D Geometry computation methods).

Thanks!

Hi there
did u manage to do it?

No man, it takes too much time to get into the solution.

You need to make a class derived from UBlueprintFunctionLibrary

then in the cpp you can use the THIRD_PARTY_INCLUDES_START and THIRD_PARTY_INCLUDES_END macros to inject your needed pure c++ code.

I also use the platformtypes includes

/// normal BlueprintFunctionLibrary code above .....

THIRD_PARTY_INCLUDES_START

#include <windows.h>
#include <stdio.h>
#include <vector>
#include <iostream>
#include <string>
#include <fstream>

#if PLATFORM_WINDOWS
#include "Windows/AllowWindowsPlatformTypes.h"
#endif

/// your custom code


#if PLATFORM_WINDOWS
#include "Windows/HideWindowsPlatformTypes.h"
#endif

THIRD_PARTY_INCLUDES_END

Then you can expose functions to blueprints through static functions.

You also need to include any runtime dependencies in your build file


RuntimeDependencies.Add(Path.Combine("$(ProjectDir)","Plugins","MyDir" , "MyNeededLibrary.dll"));


1 Like

Has anybody figured this out? Im really struggling to get CGAL into unreal 5.4