When to use RuntimeDependency vs PublicDelayLoadDLLs?
After sifting through hundreds of forms about linking and using DLLs in UE4, I still have not found a clear definition as to when to use which functions to link DLLs to a project. I am working on a plugin to connect our game project to our MySQL database. I am using MySQLCppConnector libraries and DLLs from Oracle. I had successfully build our first plugin to perform these actions, but I was not able to use them anywhere else besides plugins. I had included the proper API to the plugin to expose the module to the engine without any luck, and would receive build errors whenever I would try to include any header files from the plugin into the actual game project. After giving up on the first revision of the plugin, I decided to start from scratch. I figured the errors are probably being generated due to improper linking of the MySQL dll and lib files. My first implementation used PublicIncludePaths.Add(IncludesPath, "cppconn"), PublicDelayLoadDLLs(DLLName) where DLLName was the absolute path to the DLL file, and PublicAdditionalLibraries.Add(LibraryName) where LibraryName was the absolute path to the .lib file for the DLL. Again, I would have no build errors until I tried to include the Class headers of the plugin in the module via C++. It works fine in strictly blueprints. So, after looking at how another developer laid out his code for a VLC plugin that uses DLLs, I noticed that he is using RuntimeDependencies.Add(new RuntimeDependency(AbsolutePathToDll) but doesn't use the PublicIncludePaths.Add() or PublicDelayLoadDLLs() functions. I've also noticed that some will manually import/export the dll functions, defining each function that they need from the DLL file. I didn't think that was necessary when working with DLLs, at least not on past projects I've worked with. What does each function actually do and when should I use them to properly link a DLL file with the non static .lib and the proper includes directories containing the DLLs functions? I've had a pretty hard time figuring out how to use DLLs in the engine and have finally come to the point of posting for help. Thanks in advanced for any help or advice you can give. I think I've about exhausted Google's search engine on this topic. :) haha
I had a lot of trouble linking to a DLL as well. The tutorials are insufficient as far as I can tell. Fortunately, a recent update (4.14 IIRC) revamped the plugin system and now you can have the editor generate a plugin (framework) for you. Go into Edit->Plugins and there's a "New plugin" button. One of the options is to create a "Third Party Library" plugin. That's the one you want. Replace the default lib/DLL with the one(s) you want to use.
It may take some finagling. It did for me but I was able to get UE4 to load and use my DLL. Good luck!
answered Jun 11 '17 at 05:18 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here