Thread overview
compile x64 .dll and .so without dependencies
Mar 05, 2023
novice2
Mar 05, 2023
Guillaume Piolat
Mar 05, 2023
novice2
March 05, 2023

It there any recipe to compile x64 .dll without dependencies?

I mean it shoud be used without installing things like msvcr120.dll.
Dependencies on system dll (advapi32.dll, kerner32.dll) is ok.

I don't experiment on linux yet. But interest too.

March 05, 2023

On Sunday, 5 March 2023 at 06:36:05 UTC, novice2 wrote:

>

It there any recipe to compile x64 .dll without dependencies?

I mean it shoud be used without installing things like msvcr120.dll.
Dependencies on system dll (advapi32.dll, kerner32.dll) is ok.

I don't experiment on linux yet. But interest too.

What we do here in dub.json, for no deps on big 3 desktop OSes:

"targetType": "dynamicLibrary",
"dflags-linux-dmd": ["-defaultlib=libphobos2.a"],
"dflags-osx-ldc": ["-static"],
"dflags-linux-ldc": ["-link-defaultlib-shared=false"],
"dflags-linux-x86_64-ldc": ["-fvisibility=hidden"],
"dflags-windows-ldc": ["-mscrtlib=libcmt","-fvisibility=hidden", "-link-defaultlib-shared=false"],

Additionally on (Windows + DUB + LDC), you will need to set an envvar:
DFLAGS=-fvisibility=hidden -dllimport=none

else you may still depend upon a dynamic phobos.
It's unfortunate situation for such a common requirement...

March 05, 2023

On Sunday, 5 March 2023 at 18:35:58 UTC, Guillaume Piolat wrote:

>
"targetType": "dynamicLibrary",
"dflags-linux-dmd": ["-defaultlib=libphobos2.a"],
"dflags-osx-ldc": ["-static"],
"dflags-linux-ldc": ["-link-defaultlib-shared=false"],
"dflags-linux-x86_64-ldc": ["-fvisibility=hidden"],
"dflags-windows-ldc": ["-mscrtlib=libcmt","-fvisibility=hidden", "-link-defaultlib-shared=false"],

Additionally on (Windows + DUB + LDC), you will need to set an envvar:
DFLAGS=-fvisibility=hidden -dllimport=none

Thank you!