Include Unreal Headers in my project

Hi Everybody,
i am working on a project that needs to load dynamic libraries at runtime (.dylib because i am under macos).
I am able to load my (very simple) library using FPlatformProcess::GetDllHandle and FPlatformProcess::GetDllExport. I would like to include Unreal Headers to have a valid reference to Unreal Engine Object ( as such as AActor and so on…). I do not need implementation because those dll will be loaded inside main game.
When i try to include Engine.h or whatelse i get a bunch if errors.
Is there a “right way” to generate dylibs that use Unreal Objects?
Thanks everybody

You probably want to create a module/plugin type project. See if this page from the UE4 wiki helps

Thanks. I used modules, following link you provided, and i achieved a good enough result