On Tuesday, 9 January 2018 at 03:50:25 UTC, Dylan Graham wrote:
On Monday, 8 January 2018 at 09:01:29 UTC, Benjamin Thaut wrote:
I'm waiting on VS2015 and Windows SDK to install. Once that's
done, I'll begin testing.
Also, thanks a tonne for doing this.
I've done a test that mimics that the planned plugin system for
my game.
There is a core/engine which is built as a DLL. It exports a
class called PluginBase. It also exports a function called
getPlugins (to be run from an executable) that searches for
plugin DLLs and calls a function from those plugin DLLs that
returns their own override of PluginBase. It then runs a few
functions on the object and prints the typeid().
The core is built with:
dmd -m64 -shared -useshared -version=Shared -H pluginbase.d
-L/IMPLIB:pluginbase.lib
The resulting pluginbase.di and pluginbase.lib is copied into the
directory of Plugin1 which builds against them.
Command: dmd -m64 -shared -useshared plugin1.d pluginbase.lib
I then made an executable that builds against pluginbase and
calls getPlugins().
Command: dmd -m64 -useshared app.d pluginbase.lib
pluginbase.dll and plugin1.dll are placed next to the executable.
Running it prints this:
PS C:\dmd-dll\test\execut> ./app.exe
Plugin1 -- (name of plugin defined by
overriden class)
Hello world from Plugin1 -- (function of that class)
plugin1.Plugin1 -- (typeid of that class)
It's pretty basic but I'm glad it works. I'll try doing something
more advanced.