Using a plugin in C++ code

fszczemton,

Your solution works, but keep in mind that the plug-in is now no longer really a plug-in: it became a hard dependency that is statically linked to your project, which means that your project is coupled to the plug-in and won’t work if the plug-in is missing.

We generally discourage the adding of hard dependencies to plug-ins, because for plug-ins to be truly pluggable, the application consuming those plug-ins shouldn’t have to know about what those plug-ins are. If the app needs to know which plug-ins exist, then what’s the point of having plug-ins? :slight_smile:

That being said, if you want to go this path anyway, you may want to consider making it a somewhat less tight coupling by using DynamicallyLoadedModuleNames in combination with PrivateIncludePathModuleNames instead. This will then allow you to do a LoadModule() in your code and fail gracefully in case the plug-in is missing.

If you do not need access to any of the implementation details of the plug-in, but you simply want to load the plug-in as part of loading your game or your game’s Editor, then it is sufficient to add the plug-in as a dependency to your game’s Engine.ini mark the plug-in as enabled in the .uplugin file.