Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Loading DLLs from Plugins

Hi guys,

I am in the process of creating a plugin that will load the Mono runtime, and allow scripting of the Unreal Engine using any Mono-supported CIL language.

I have this process running successfully, however I am looking to now clean the package up somewhat. Namely; I wish to provide all required third-party libraries within the plugin folder structure.

For example:

Is there a system in place within the plugin architecture to allow me to define the search path for loading of required third-party libraries?

I would rather not pollute the binaries (or Third Party!) directory with additional DLLs exclusively for my plugin if at all possible.

Thanks! :)

Product Version: Not Selected
more ▼

asked Apr 08 '14 at 11:23 AM in C++ Programming

avatar image

56 2 5 6

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

This has been addressed for 4.8!

It is now possible to include third-party dependencies directly in the plug-in folder without having to manually copy them to the Engine directory. I have attached a ZIP file that contains a sample plug-in project, which includes a fake third-party module in the form of full source code. Having source code for the dependency is generally preferred, because developers can then simply compile everything for whatever platform they need.

However, source code is not always available. In many cases you only have a pre-compiled DLL or Dylib that you wish to include. Those, too, are supported in plug-ins now. The attached example does not currently show this workflow, but I have attached a second file from a VLC plug-in that I am currently working on. I hope to have the entire code on GitHub later today or tomorrow - then you can take a close look at how it's done.

The main trick for pre-compiled libraries is the RuntimeDependencies array, which is used to tell UBT about those third-party libraries. When packaging a project, those files will then automatically be included.

Another complication that sometimes arises is that DLLs have to be bound dynamically at run-time (especially when LGPL licensed), i.e. via LoadLibrary(), GetProcAddress() and similar mechanisms. This can be accomplished with FPlatformProcess::GetDllHandle() and passing in the path to the plug-ins third party directory. For example, I use the following to get the correct path in my VLC plug-in:

 const FString BaseDir = IPluginManager::Get().FindPlugin("VlcMedia")->GetBaseDir();
 const FString VlcDir = FPaths::Combine(*BaseDir, TEXT("ThirdParty"), TEXT("vlc-2.2.2"));

I will update this answer when I have the VLC code checked in. Then you can look at a working example.

more ▼

answered Jun 17 '15 at 03:35 PM

avatar image Spiris Jun 17 '15 at 04:15 PM

Whoops, it still is telling me the DLL is missing for the game builds. Editor build works though. Looking forward to that example.

avatar image gmpreussner STAFF Jun 19 '15 at 11:20 PM


I have not tried this with a packaged build yet, so it may not actually work as expected. I will check with the UBT owner on Monday.

avatar image Jin_VE Jul 17 '17 at 09:41 PM

This method does not copy my DLL into the binaries directory when I package a dedicated server. Not sure about any other target. If I give it a bad source path then the packaging fails, but if I give it a good path then it doesn't copy the DLL.

avatar image gmpreussner STAFF Jul 18 '17 at 02:32 AM

You're missing the RuntimeDependencies settings in your Build.cs. That will copy the files to the target when packaging.

avatar image Jin_VE Aug 04 '17 at 08:55 AM

But I do have it in there. RuntimeDependencies.Add(new RuntimeDependency(ModuleDirectory + "\\DLL\\libzmq.dll")); I tried doing it from my third party library and the plugin that uses it. Neither worked.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

Update: This has been addressed in 4.8. See my other answer!

This is a great question, and you're not the first person to ask :)

The bad news is that, currently, you have to manually copy the third party DLLs into the ThirdParty or Engine/game Binaries directory. This will, as you pointed out, pollute those directories.

The good news is that this is on our radar. We already have a TTP for it, and we will try to fix this as soon as possible. The goal is to allow for third-party DLLs in the plug-in's Binaries directory or some other directory inside the plug-in folder, so that plug-ins are completely self contained.

more ▼

answered Aug 19 '14 at 06:19 PM

avatar image Grey Aug 20 '14 at 03:32 AM

Thank you for this update. I have been using the third party directories currently, but knowing there are plans for this is a very good thing in my opinion. :)

avatar image gmpreussner STAFF Aug 20 '14 at 04:01 PM

Had a discussion about this yesterday with some other folks, and the plan is to have this fixed for 4.5.

avatar image OwenWP Oct 01 '14 at 10:21 PM

I did this, putting my custom DLL in Binaries/ThirdParty, and that works in the editor. But when I try to cook my game and run a packaged build, or launch from editor, it does not copy the DLL over and fails to run. I see that third party DLLs for Ogg Vorbis and PhysX get copied into the packaged build automatically, but I can't tell how this is done or what they are doing differently. The only way I can get it to work is to manually copy the DLL over every time I package a build.

edit: I figured it out. There is a monolithic automation script that I needed to add my dll to, In XPlatform.Automation.cs GetFilesToDeployOrStage. To save pollution this also involved adding a bUsingX flag to the ProjectParams, and having my game target config set it to true.

avatar image 3dids Nov 28 '14 at 05:23 PM

Any update on this? Is there something in 4.5 or 4.6?

avatar image xYz Dec 03 '14 at 02:41 PM

I would second on this, also is there a workaround or a build step that you can attach to? Manually copying the needed dlls is quite a burden.

avatar image Spiris Jun 17 '15 at 01:47 AM

I am currently struggling with this same issue. Has there been a solution that hasn't been linked here? Has there been a decision to not include this functionality? It would be good to get an update of any kind after such a long period of silence.

avatar image gmpreussner STAFF Jun 17 '15 at 03:36 PM

This is now supported in 4.8. I have added another answer.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question