On Tuesday, 2 March 2021 at 04:26:52 UTC, Pillager86 wrote:
On Tuesday, 2 March 2021 at 04:13:31 UTC, Pillager86 wrote:
On Tuesday, 2 March 2021 at 03:42:14 UTC, Pillager86 wrote:
Update: the dub "dynamicLibrary" target option is busted on Windows and does not build anything at all. This should be filed as a bug.

Update again: I got the Windows DLL to build and run without crashing, but I don't know how to put specific platform options in dub. I need "dflags" "-defaultlibrary=phobos2" or something on Linux but not Windows.

Try this (for dub.json)

"dflags-linux": ["-defaultlibrary=phobos2"]

For platform/architecture/compiler specific variants just add suffix like this, also works with lflags, and I guess pretty much any other options.

"dflags-linux" : ["specific flags for linux"]
"dflags-windows" : ["specific flags for windows"]
"dflags-windows-dmd" : ["more flags if building with dmd"]
"dflags-windows-dmd-x86" : ["even more flags if building for x86 using dmd"]

Also, what do you do if the shared library needs to refer to types in the main static library?


You need to link it with your DLL, this will however will create lots of duplicated symbols in your executable.

In most cases this is undesireable, so instead one will usually put all common stuff into DLL and share across main executable and other DLL's that relies on it.

On Windows however DLL support is unfinished, so you are stuck with hacks and/or static libs option.

Reply via email to