Help in compiling C++ code external to UE4 (it's a sort of library)

Your library needs to be part of an existing module or in its own module.
Copy your source folder to the right module folder, regenerate the project files and the build system should be aware of your library.
In order to access types and functions defined in your library from other modules, they need to be exported. You do that by adding the “MODULENAME_API” macro before the type/function name.
Example from the navmesh module :


class NAVMESH_API dtCrowd{...};

Now dtCrowd can be directly accessed by other modules.