I'm using stdio.h , string.h , math.h in a simple math tool written in C.
I hear that -static in gcc does not actually always statically compile libraries (i hear this from Linux-pro jargon which i don't understand) and I also hear from the same sources that software development for Linux is a pain due to fragmentation and different distributions requiring re-compilation for each one.
Since i'm not doing a GUI or a custom library , or anything too complex, I hypothesise that i dont have to compile again for each distro and statically linking with -static in gcc while compiling on my Ubuntu 20.04 system will create an executable binary compatible with nearly all x86_64 Linux systems. Am I right ? Will it work across at least Debian, Ubuntu , Arch and their derivatives ?
I saw a video of Garry from Android Authority who statically compiled his C program he made on a Raspberry Pi and ran it on Android, so i'm guessing this is possible.
From the headers you list, the only dependency on dlopen
is implied by the mode argument of fopen
: If the ,ccs=
parameter is used there, fopen
will try to dlopen
a gconv module, for character set conversion.
Apart from that, none of the functions declared in <stdio.h>
, <string.h>
, <math.h>
will perform an implicit dlopen
, so static linking should be safe in this particular case.