www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - dub ldc2 static linking

reply Yura <yuriy.min gmail.com> writes:
Dear All,
I am trying to create a static executable to be able to run it on 
virtually any linux x86_64 OS. At the end I get a binary, 
however, multiple warnings are printed after compilation.

My dub.sdl:

dependency "mir" version="~>3.2.3"
dependency "lubeck" version="~>1.5.1"
lflags "-lopenblas" "-lgfortran"
dflags "--static" "-O3"

dub build --force --compiler=path_to_ldc/ldc2

curl.d:(.text._D3std3net4curl7CurlAPI7loadAPIFZPv+0xd): warning: 
Using 'dlopen' in statically linked applications requires at 
runtime the shared libraries from the glibc version used for 
linking

and many other warnings like this.

What am I doing wrong? Any way to fix it?
Oct 27 2022
next sibling parent reply Anonymouse <zorael gmail.com> writes:
On Thursday, 27 October 2022 at 08:08:38 UTC, Yura wrote:
 What am I doing wrong? Any way to fix it?
https://forum.dlang.org/thread/gghcyaapjwfcpnvkswef forum.dlang.org worked for me.
Oct 27 2022
parent Yura <yuriy.min gmail.com> writes:
Thank you! I tried this one, but it did not help. All these 
warnings survived :
"... Using 'getservbyport' in statically linked applications 
requires at runtime the shared libraries from the glibc version 
used for linking"

On Thursday, 27 October 2022 at 14:18:01 UTC, Anonymouse wrote:
 On Thursday, 27 October 2022 at 08:08:38 UTC, Yura wrote:
 What am I doing wrong? Any way to fix it?
https://forum.dlang.org/thread/gghcyaapjwfcpnvkswef forum.dlang.org worked for me.
Oct 27 2022
prev sibling next sibling parent reply kinke <noone nowhere.com> writes:
For fully static linking on Linux, you'll need to move away from 
glibc to e.g. the musl C runtime, as used by the Alpine distro.
Oct 27 2022
parent reply ryuukk_ <ryuukk.dev gmail.com> writes:
On Friday, 28 October 2022 at 01:35:04 UTC, kinke wrote:
 For fully static linking on Linux, you'll need to move away 
 from glibc to e.g. the musl C runtime, as used by the Alpine 
 distro.
I'm just right now having an issue with glibc version mismatch for my server, so i'm looking to move to musl to avoid that kind of issues Is there any guide to compile ldc with musl and then static link it?
Oct 27 2022
next sibling parent reply ryuukk_ <ryuukk.dev gmail.com> writes:
On Friday, 28 October 2022 at 02:46:42 UTC, ryuukk_ wrote:
 On Friday, 28 October 2022 at 01:35:04 UTC, kinke wrote:
 For fully static linking on Linux, you'll need to move away 
 from glibc to e.g. the musl C runtime, as used by the Alpine 
 distro.
I'm just right now having an issue with glibc version mismatch for my server, so i'm looking to move to musl to avoid that kind of issues Is there any guide to compile ldc with musl and then static link it?
Actually nvm, `-static` as mentioned above seems to be enough
Oct 27 2022
parent Sergey <kornburn yandex.ru> writes:
On Friday, 28 October 2022 at 04:02:15 UTC, ryuukk_ wrote:
 On Friday, 28 October 2022 at 02:46:42 UTC, ryuukk_ wrote:
 On Friday, 28 October 2022 at 01:35:04 UTC, kinke wrote:
 For fully static linking on Linux, you'll need to move away 
 from glibc to e.g. the musl C runtime, as used by the Alpine 
 distro.
I'm just right now having an issue with glibc version mismatch for my server, so i'm looking to move to musl to avoid that kind of issues Is there any guide to compile ldc with musl and then static link it?
Actually nvm, `-static` as mentioned above seems to be enough
Static on alpine is possible - be aware of ‘ldc-static’ package. But static and LTO is something harder.. is it even possible without re-compilation of ldc-runtime? https://forum.dlang.org/thread/newwjfrebckphgwgarvq forum.dlang.org
Oct 27 2022
prev sibling parent reply Kagamin <spam here.lot> writes:
On Friday, 28 October 2022 at 02:46:42 UTC, ryuukk_ wrote:
 I'm just right now having an issue with glibc version mismatch 
 for my server
Just compile with an old enough glibc, 2.14 works for me.
Oct 28 2022
parent Yura <yuriy.min gmail.com> writes:
On Friday, 28 October 2022 at 09:02:22 UTC, Kagamin wrote:
 On Friday, 28 October 2022 at 02:46:42 UTC, ryuukk_ wrote:
 I'm just right now having an issue with glibc version mismatch 
 for my server
Just compile with an old enough glibc, 2.14 works for me.
Indeed, if I got it right it seems to be much easier and straightforward than recompiling virtually everything you touch against musle, starting from Blas, druntime library, etc.
Oct 28 2022
prev sibling parent reply Mike Parker <aldacron gmail.com> writes:
On Thursday, 27 October 2022 at 08:08:38 UTC, Yura wrote:

 curl.d:(.text._D3std3net4curl7CurlAPI7loadAPIFZPv+0xd): 
 warning: Using 'dlopen' in statically linked applications 
 requires at runtime the shared libraries from the glibc version 
 used for linking

 and many other warnings like this.

 What am I doing wrong? Any way to fix it?
This has nothing to do with dub and is not a D issue specifically. Enter your error message in Google and you'll get a long list of results. Maybe one of them can help you.
Oct 27 2022
parent Mike Parker <aldacron gmail.com> writes:
On Friday, 28 October 2022 at 01:37:50 UTC, Mike Parker wrote:

 This has nothing to do with dub and is not a D issue 
 specifically. Enter your error message in Google and you'll get 
 a long list of results. Maybe one of them can help you.
Or do what kinke suggests :-)
Oct 27 2022