How can I create a plugin library?

I want to extend the functionality of Ue4 and I have already looked at plugins but I am not sure how I would create a c++ library that I can easily share between projects.

I only need to expose some functions and I don’t need a cpp file.

I started with the BlankPlugin and I changed all the names, I deleted the private folder and changed the Build file to

namespace UnrealBuildTool.Rules
{
	public class Functional : ModuleRules
	{
		public Functional(TargetInfo Target)
		{
			PublicIncludePaths.AddRange(
				new string[] {
				    "Developer/Functional/Public"
				}
				);
...

The public folder only contains one file, functional.h with the content of

#pragma once

void foo{}

The plugin sits in my current Ue4 project. How would I access ‘foo’ in my Ue4 project?

I mean I can access it if I include the header like this

#include "../../Plugins/Developer/Functional/Source/Functional/Public/Functional.h" 

But that’s bypassing the Ue4 plugin functionality

First you should determine whether you want to create a plugin module or a library module. Plugins are usually a self-contained module (or set of modules) that implement some API to extend functionality in the Editor or a game. A library on the other hand is a module whose functionality can be shared with other modules. It’s possible and not uncommon to implement a plugin that also contains some library modules that the plugin uses internally.

From your description it sounds like you just want to implement a module that can be shared between projects, so it’s not really a plugin (but other plugins may use it). You would create that just like any other regular module.

If you provide more details on which modules you will have in your plugin and how they depend on each other, then I can help with you correctly setting up the module dependencies. In general, any module referencing a shared module must have a module dependency to that shared module in its Build.cs file. It must also include one or more public headers from the shared module that declare the shared module’s API. The module that implements the actual plugin (i.e. implements some Editor or Game API and hooks into the Editor or Game) does not need any public header files since it won’t be used by anything else. You will have to set up the .uplugin file correctly, so that this module is loaded as a plugin.

By the way, the PublicIncludePaths array is no longer needed. All public header files in a module are now detected automatically. This is not the case the private header files, so the PrivateIncludePaths array is still needed if you have header files in subfolders within your Private directory.

Thank you for the response, I probably want to create a ‘library module’. Basically I want to extend the functionality of TArray by adding some functions like map fold etc.