Packaging a third-party library with a plugin for Unreal Marketplace

In this thread, I show a way to include a static Third-Party (.lib) with a plugin. It is necessary to put the third-party library (code, includes and .lib files) into the following location:

  /(ProjectName)/Plugins/(PluginName)/Source/ThirdParty

For this example, I’m adding “libsodium.lib” to the plugin. In my case, the library (libsodium.lib) is located at:

  /(ProjectName)/Plugins/(PluginName)/Source/ThirdParty/libsodium/Build/Release/x64

Change (PluginName).Build.cs to add a path to the include files and create a dependency to the third-party software as follows:

    string SodiumIncludes = Path.Combine(ModuleDirectory, "../ThirdParty/libsodium/");
    PublicDefinitions.Add("SODIUM_STATIC=1"); // library-specific definition
    PublicDefinitions.Add("SODIUM_EXPORT="); // library-specific definition

    PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
	
	PublicIncludePaths.AddRange(
		new string[] {
			SodiumIncludes
			// ... add public include paths required here ...
		}
		);
			
	
	PrivateIncludePaths.AddRange(
		new string[] {
                           // ... add other private include paths required here ...
		}
		);
		
	
	PublicDependencyModuleNames.AddRange(
		new string[]
		{
                           "Core",
			// ... add other public dependencies that you statically link with here ...
		}
		);
		
	
	PrivateDependencyModuleNames.AddRange(
		new string[]
		{
                           "CoreUObject",
			"Engine",
			"Slate",
			"SlateCore",
			// ... add private dependencies that you statically link with here ...	
		}
		);
	
	
	DynamicallyLoadedModuleNames.AddRange(
		new string[]
		{
			// ... add any modules that your module loads dynamically here ...
		}
		);
    string PlatformString = (Target.Platform == UnrealTargetPlatform.Win64) ? "x64" : "Win32";
    string path = Path.Combine(ModuleDirectory, "../ThirdParty/libsodium/Build/Release/" + PlatformString + "/libsodium.lib");
    PublicAdditionalLibraries.Add(path);

This is minimum required for plugins to use a static third-party library and be compatible with Unreal Marketplace publishing requirements.

The Third Party Software (TPS) Usage form must also be completed. For each TPS listed, the following questions must be answered in the description field:

What does this Software do?
Why does your plugin need it?
Is the library statically or dynamically linked?
Will this software send data back to the creator?

The form can be found here: Third Party Software Declaration Form - Formstack

Lastly, once the above has been completed, the new version of the product will be subject to a legal review process, to confirm that this Third Party Software can be used in your Marketplace product. Legal review takes an average of 2-4 weeks to complete. Once legal review has completed and the software is approved for use, you may submit a file update for your product with the new files including the TPS.