Build Unreal as a Library - expanding the API?

Hello, I’ve followed this documentation as much as I could: Building Unreal Engine as a Library | Unreal Engine 4.27 Documentation
The last part of the documentation, where it says “Expanding the API”.
The part where I’m confused is that it says “Write any additional functions your application needs and use the UELIBRARYAPI macro to expose them.” I’ve tried many different ways to get this to work. I’ve tried putting the UELIBRARY macro in front of functions I’m trying to write in the UELibraryProject.cpp source file, I’ve tried __declspec(dllexport) instead, since someone else in the unreal forums said that worked for them. I’ve tried adding the exported dll UELibraryEmbeddedEditor.dll as a reference manually to the UELibraryApp project. I’ve done a bunch of research on how to simply import a DLL in C++ generally. I can’t get this to work.
If anyone could basically explain how it is supposed to work, or an example of what I’m supposed to write as far as new functions, that’d be very helpful.

New update, I still cannot get this to work properly. Below, I have documented some attempts so far, for informational purposes.

I have been able to call functions from the EmbeddedEditor DLL, but only by using LoadLibrary and GetProcAddress. This is definitely not the intended solution, and from what I can gather in my testing, Data Execution Prevention makes this a very bad and unreliable way to do this.

Through research, I have a better understanding on how this works, and I’ve tried another method of getting this to work, still to no avail. My new attempt has been to edit the project file and I added these definitions to the “NMakePreprocessorDefinitions” of the UELibraryProjectEmbeddedEditor project file: UE_LIBRARY_DLL_EXPORT;IS_MONOLITHIC;UE_LIBRARY_ENABLED=1

I’ve also tried adding the EmbeddedEditor DLL and/or LIB file as a reference to the UELibraryApp project, but it appears that they cannot be used this way. I lack the knowledge for why that is.

My next attempt will be to copy the way that the UELibrary module is included in the UELibraryApp project. For this, the UELibrary directory that contains the UELibraryAPI.h header located in the Engine source is included as an extra include directory in the UELibraryApp project. This directory is located at: <UE_INSTALL_LOCATION>\UnrealEngine\Engine\Source\Runtime\UELibrary\Public So to replicate this, I am including the directory where UELibraryProject.h is located as an extra include directory in the UELibraryApp project as well. I expect this to fail as well, as The UELibraryApp project has no direct references to the Unreal Engine source code, so any code that includes FString or any Unreal data types will probably fail.

After this, I think the next thing I will take a look at is the Unreal Engine version. I’m trying to do this in UE5, maybe it only works right now in UE 4.27, as the documentation lists. As far as I can tell, it should work with UE5, but the docs were written for 4.27, so at this point it’s worth testing out.

At least I’m documenting my attempts and trying something, as it seems like nobody else knows much about the subject. Hopefully the information in these posts will be valuable to someone who tries to get this to work in the future.

Necroing this thread, as I’ve started working on this again, and it’s my own thread anyways.
I’ve gotten it to compile in 5.3, and I can run the UELibraryApp.exe program. However, expanding the API still seems to be an issue for me. I came across a source of information on the community here where someone said that instead of using the UELIBRARYAPI macro, they used the _declspec(dllexport) label manually to specify things they need to export and use instead.
A second point that I’d like to know is whether licensing is an issue here. I am not trying to make a commercial product, so I am not sure if it would be a problem.