x

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"

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

Product Version: UE 4.15
Tags:
more ▼

asked May 03 '17 at 07:38 PM in C++ Programming

avatar image

ENiari Games
66 4 8 12

avatar image ENiari Games May 03 '17 at 07:50 PM

I forgot to clarify, I wouldn't receive build errors on my first revision, but after trying to launch the editor, it would stop at apx 75% notifying me that the module was not setup properly / not loaded correctly. The editor would load up fine if I didn't include any class header files from the plugin into the game project. And everything would work great on the blueprints end, but that cripples me on the coding side.

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

1 answer: sort voted first

Hi!

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!

more ▼

answered Jun 11 '17 at 05:18 AM

avatar image

Jin_VE
4.4k 32 77 42

avatar image Jin_VE Jun 11 '17 at 05:21 AM

Also, I checked to see if there is an existing MySQL plugin and I found this. Maybe it can save you the trouble. https://forums.unrealengine.com/showthread.php?120792-MySQL-Connector-UE4-Plugin-is-available-for-all-now

avatar image ENiari Games Jul 11 '17 at 06:01 AM

Since you were the only responder, thank you. Yeah, the tutorials are pretty scarce when it comes to the core functionality of Unreal Engine 4.

So the big issue with the "MySQL-Connector-Plugin" you posted, is that it is only for Maria-DB. While that is an extension of MySQL, it won't work directly with a MySQL database. The other thing I wasn't a huge fan of the plugin, is that you have to manually edit the plugin's build file to match the name of your project. I ended up building mine so that it would auto-detect your project and set itself up by dropping it straight into your project's plugins folder. That was the whole reason I ended up building our own MySQL plugin.

So what I did figure out after finishing the plugin, was that if you drop the dll into your project's binaries folder, the engine will automatically load any .dll files it finds in there. (It makes sense, since all of the engine's dlls reside there.) So I built my plugin to add the MySQLConnector.dll file in the Binaries folder automatically. Everything seemed to work from there.

I think a lot just had to do with my lack of experience in UE4. I've worked with DLLs in my own c++ projects, but this was a first time for UE4.

Thank you Jin_VE for your help.

(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