# How to load (own) DLL in Runtime?

**URL:** <https://forums.unrealengine.com/t/how-to-load-own-dll-in-runtime/347937>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [February 19, 2016, 2:03am UTC](https://forums.unrealengine.com/t/how-to-load-own-dll-in-runtime/347937 "2016-02-19T02:03:29Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Conan](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Conan](https://forums.unrealengine.com/u/Conan)\
**Post date:** [February 19, 2016, 2:03am UTC](https://forums.unrealengine.com/t/how-to-load-own-dll-in-runtime/347937/1 "2016-02-19T02:03:29Z")

</div>

Greetings,  
for my current project I need to to bind some dlls for the game (Runtime). I tested it in the Editor (PIE) and everthing worked fine but after I packaged the game I get the error, that my dlls couldn’t be loaded. I find out that the Path from my plugin doesn’t point to a “valid” address.

How I get the plugin address

```
 IPluginManager::Get().FindPlugin("ThatCoolPlugin")->GetBaseDir();
 DllNameDir = FPaths::Combine(*PluginDir, TEXT("Binaries/Name/Win64/dllName.dll"));

```

My question is how should I bind the dll so the packaged game can find the dll?  
Currently the Binaries are stored in a “Binaries” folder in the “ThatCoolPlugin” folder, which is in the plugin folder.

How I load the Dlls

```
DllNameHandle = !DllNameDir .IsEmpty() ? FPlatformProcess::GetDllHandle(*DllNameDir ) : nullptr;

```

Some details:  
I used common ways to load unload the dll. My plugin settings (Rules) can be compared with the Third Party Library Example plugin. The major differents between these settings is, that my setting type is Runtime not development.

Edit:  
What I want to know is, what do I need to do if an plugin is from the type “Runtime”, while I load dlls?  
I saw that in the packaged Game has a Engine/Binaries/ThirdParty folder. But their are dlls such PhysX. VR, et cetera. Is it possible to write a Plugin (or something else) which store his binaries in the same folder? or in another folder where the engine can find it?

---

<div class="post-metadata">

**Author:** ![Conan](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Conan](https://forums.unrealengine.com/u/Conan)\
**Post date:** [February 27, 2016, 3:49pm UTC](https://forums.unrealengine.com/t/how-to-load-own-dll-in-runtime/347937/2 "2016-02-27T15:49:24Z")

</div>

Any advice? This is a serious issue in the current porject I’m working on.

---

<div class="post-metadata">

**Author:** ![theonecalledtom](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@theonecalledtom](https://forums.unrealengine.com/u/theonecalledtom)\
**Post date:** [February 27, 2016, 4:50pm UTC](https://forums.unrealengine.com/t/how-to-load-own-dll-in-runtime/347937/3 "2016-02-27T16:50:20Z")

</div>

My understanding is it isn’t really supported yet due to security concerns. Having said that have a dig around the UT forums because I think others have been pursuing this avenue.

Can you refactor to get the dll logic into blueprints? This should be currently supported and is the approach I’m following but it’s also a better fit for my particular distribution model.

---

<div class="post-metadata">

**Author:** ![Conan](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Conan](https://forums.unrealengine.com/u/Conan)\
**Post date:** [March 1, 2016, 11:43am UTC](https://forums.unrealengine.com/t/how-to-load-own-dll-in-runtime/347937/4 "2016-03-01T11:43:30Z")

</div>

what do you mean with refactor? To implment the dll logic into blueprint? I have access to the source code from the dll but I don’t have the permission to modify it.

---

<div class="post-metadata">

**Author:** ![theonecalledtom](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@theonecalledtom](https://forums.unrealengine.com/u/theonecalledtom)\
**Post date:** [March 1, 2016, 2:54pm UTC](https://forums.unrealengine.com/t/how-to-load-own-dll-in-runtime/347937/5 "2016-03-01T14:54:40Z")

</div>

Can you provide an actual example of what you are trying to do?

---

<div class="post-metadata">

**Author:** ![Conan](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Conan](https://forums.unrealengine.com/u/Conan)\
**Post date:** [March 1, 2016, 4:32pm UTC](https://forums.unrealengine.com/t/how-to-load-own-dll-in-runtime/347937/6 "2016-03-01T16:32:15Z")

</div>

What I’m trying can be achieved by making the “ThirdParty Plugin example” runtime capable. Just create a new “ThirdParty Plugin” then change the Type to Runtime in the .uplugin file. But after that the engine cannot finde the dll direction in the packaged game

---

<div class="post-metadata">

**Author:** ![theonecalledtom](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@theonecalledtom](https://forums.unrealengine.com/u/theonecalledtom)\
**Post date:** [March 1, 2016, 11:15pm UTC](https://forums.unrealengine.com/t/how-to-load-own-dll-in-runtime/347937/7 "2016-03-01T23:15:46Z")

</div>

I meant more like “final result in game”. Why a dll is required in the first place (why you can’t ship exe logic in a single exe and extend it in blueprints).

Honestly you’re outside my experience here but pathing in DLC is a little tricky. If you are packaging the dll within a pak file I’ve found that:

- Paths within the pak file are relative to its mount path (use the -List UnrealPak option to see where they are).
- Paths within the pak file are the relative path between the point the pak file was created at and the files that were put in it. If you create a pak file at c:\afolder\mypakfile.pak then c:\afolder\bfolder\c.file will have the path bfolder\c.file
- Mount point for a pak file is set within the FPakPlatformFile::Mount function (i.e. final path is combination of the path provided to mount AND the path within the packfile.
- There is a second mount point, for unreal content (mounting uassets into the unreal asset browsing system). This is setup using FPackageName::RegisterMountPoint
- For this second mount point new calls with and old mountpoint will replace previous calls, so you can’t mount two things to /DLC/ you’ll need /DLC1/ and /DLC2/

Really not sure if any of this helps you! Can you see the dll in the final packaged game directory structure?

Again, you’re outside my experence but mounting a dll sounds likely platform specific and something that has seemed not supported in the few places I’ve come across it, but I look forward to someone chiming in here and detailing how its going to work (especially in a nice wrapped up portable manner!).

Good luck 🙂

---

<div class="post-metadata">

**Author:** ![Shadowriver](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Shadowriver](https://forums.unrealengine.com/u/Shadowriver)\
**Post date:** [March 2, 2016, 1:01am UTC](https://forums.unrealengine.com/t/how-to-load-own-dll-in-runtime/347937/8 "2016-03-02T01:01:29Z")

</div>

What Pak has anything to do with this? All dll should be outside of any achieve to be usable

---

<div class="post-metadata">

**Author:** ![Shadowriver](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Shadowriver](https://forums.unrealengine.com/u/Shadowriver)\
**Post date:** [March 2, 2016, 1:03am UTC](https://forums.unrealengine.com/t/how-to-load-own-dll-in-runtime/347937/9 "2016-03-02T01:03:49Z")

</div>

Did you tried this set up? if you can you should link dll staticly to UE4 module.

> **[A new, community-hosted Unreal Engine Wiki](https://forums.unrealengine.com/t/a-new-community-hosted-unreal-engine-wiki/141494)**
>
> After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — https://unrealcommunity.wiki/! You will be able to find content from...

---

<div class="post-metadata">

**Author:** ![Conan](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Conan](https://forums.unrealengine.com/u/Conan)\
**Post date:** [March 3, 2016, 11:21pm UTC](https://forums.unrealengine.com/t/how-to-load-own-dll-in-runtime/347937/10 "2016-03-03T23:21:53Z")

</div>

I didn’t try it because I want to link dynamic not static. But I don’t see any way to achive this. I will mark your answer as best because at least it solve the problem. I hope this will be possible in the future 🙂  
thanks for the helpful answer 🙂

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_4584d52b](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_4584d52b](https://forums.unrealengine.com/u/anonymous_user_4584d52b)\
**Post date:** [October 29, 2018, 3:23am UTC](https://forums.unrealengine.com/t/how-to-load-own-dll-in-runtime/347937/11 "2018-10-29T03:23:44Z")

</div>

Hi , did you ever work out a solution for this? Sorry that everyone else posting gave you such a crappy answer ☹
