# Specify dll location using plugin in cooked project?

**URL:** <https://forums.unrealengine.com/t/specify-dll-location-using-plugin-in-cooked-project/436693>\
**Category:** Plugins\
**Tags:** dll, unreal-engine, Packaging, Plugins, question\
**Created:** [October 30, 2018, 9:50am UTC](https://forums.unrealengine.com/t/specify-dll-location-using-plugin-in-cooked-project/436693 "2018-10-30T09:50:53Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Jay2645](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Jay2645](https://forums.unrealengine.com/u/Jay2645)\
**Post date:** [January 25, 2019, 10:44am UTC](https://forums.unrealengine.com/t/specify-dll-location-using-plugin-in-cooked-project/436693/2 "2019-01-25T10:44:36Z")

</div>

This is a few months old, but since nobody has answered you, there are 2 steps:

1. Copy the .dll file into the Binaries folder
2. Adding the _copied_ DLL to the runtime dependencies.

Everything below goes into your .build.cs file.

First, a couple helper functions to copy the DLL:

```
public string GetUProjectPath()
{
	return Path.Combine(ModuleDirectory, "../../../..");
}

private string CopyToProjectBinaries(string Filepath, ReadOnlyTargetRules Target)
{
	string BinariesDir = Path.Combine(GetUProjectPath(), "Binaries", Target.Platform.ToString());
	string Filename = Path.GetFileName(Filepath);

	//convert relative path 
	string FullBinariesDir = Path.GetFullPath(BinariesDir);

	if (!Directory.Exists(FullBinariesDir))
	{
		Directory.CreateDirectory(FullBinariesDir);
	}

	string FullExistingPath = Path.Combine(FullBinariesDir, Filename);
	bool ValidFile = false;

	//File exists, check if they're the same
	if (File.Exists(FullExistingPath))
	{
		ValidFile = true;
	}

	//No valid existing file found, copy new dll
	if (!ValidFile)
	{
		File.Copy(Filepath, Path.Combine(FullBinariesDir, Filename), true);
	}
	return FullExistingPath;
}

```

Next, make the DLL a dependency so it gets copied automatically:

```
string pluginDLLPath = PATH_TO_YOUR_DLL_FILE;
string binariesPath = CopyToProjectBinaries(pluginDLLPath, Target);
System.Console.WriteLine("Using Python DLL: " + binariesPath);
RuntimeDependencies.Add(binariesPath);
```

---

_[View the full topic](https://forums.unrealengine.com/t/specify-dll-location-using-plugin-in-cooked-project/436693)._
