I’m not totally sure this is exactly the right way to approach the problem or not, but when you understand, really understand, how something works it makes it easier to produce quality content.
I really wanted to understand how the Third Party Library template works. First step is to open/create a game. And it needs to be a C++ game not a Blueprint game. Apparently you can’t see the advance choices from the green “New Plugin” button if you created the original game as a blueprint. In a new C++ game, the “New Plugin” button displays:
- Blank
- Content Only
- Blueprint Library
- Editor Toolbar Button
- Editor Standalone Window
- Editor Mode
- Third Party Library <— use this choice for the quick test
Create a new Third Party Library plugin. Lets call it something fancy, “abc”. The plugin gets built “Generating Code” and you will see a popup window “Third Party Plugin” “Loaded ExampleLibrary.dll from Third Party Plugin sample.” That tells you the plug was installed, built and successfully run. You can analyse the code contained within the Plugin folder via Visual Studio. Check and understand each and every file contained within, particularly the C# files: “abc.Build.cs” and “abcLibrary.Build.cs”. Note carefully the file structure…
Plugins
abc
-Binaries
ThirdParty
abcLibrary
Win64
Win64
-Content
-Intermediate (contains Build --> Win64 --> UE4Editor-->Development-->abc folders)
-Resources
-Source
abc
Private
Public
ThirdParty
abcLibrary
ExampleLibrary (with folder ExampleLibrary.xcodeproj)
ExampleLibrary.xcodeworkspace
Mac
Release
x64
Release
What happens here is that the original content of the plugin contains that which is held within Source, Resources and Content folders. The other root folders, Binaries and Intermediate are generated folders, propagated when you add the plugin (remember the “Generating Code” popup?) And when you really dissect the code, the magic is that the abcLibrary .dll / .lib files are copied from Source into Binaries/ThirdParty folder as appropriate.
At this point we haven’t done a thing. Push a button, create a new plugin, give it a name, and look closely at stuff. Now, lets do a little test. Close the game engine, close visual studio. Delete the entire Binaries folder and delete the entire Intermediate folder. Open up Visual Studio for the game project, then rebuild. What should happen is those two folders (Binaries and Intermediate) should rebuild. But here’s the rub. That doesn’t work. The Binaries/ThirdParty folder is gone forever. And when that’s gone, the plugin fails When you open the game you will see a white box popup “Message” “Failed to load example third party library”.
I’m not getting this. Why is the original build (after the Green add New Plugin button is pushed) so much different than the Visual Studio / UE4 engine rebuild process? What this means in real life is if you are trying to introduce a real third party plugin with contained .lib/.dll precompiled libraries, they will NEVER propagate over to the Binaries folder.
Note, in the abcLibrary.Build.cs file I do see the line
// Ensure that the DLL is staged along with the executable
RuntimeDependencies.Add("$(PluginDir)/Binaries/ThirdParty/abcLibrary/Win64/ExampleLibrary.dll");
I would think that should do it? And note, I do see the origin of that code here.
Am I doing this wrong? Can anybody explain what’s happening here?