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

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