compile x64 .dll and .so without dependencies

Guillaume Piolat first.last at spam.org
Sun Mar 5 18:35:58 UTC 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...


More information about the Digitalmars-d-learn mailing list