|
|
Hello,
I'm trying to build a binary that runs on as many linux distrubutions
as possible. At first glance this seems easy because in my case the
binary does not depend on any libraries. But there are still the
"standard system libraries" which the linker includes automatically
unless -nodefaultlibs or -nostdlib is set. I'm trying to understand
these libraries now. On these I have several questions which I could
not answer with Google.
1.) Where can I find a ful list of these standard system libraries?
(Or, more basically, does a request for such a list make sense?)
2.) How does the compiler decide wich standard system libraries
actually to include? I found (using ldd or objdump) that a hello-world
program does not include any. My program depends on stdc++, c, gcc_s,
and m, of which gcc_s is only needed indirectly (by stdc++) and m not
at all.
3.) What does -static link into my executable? Am I correct to assume
that above four libraries are linked statically into my executable?
Does that mean that libc is linked statically and the result depends
on the (L)GPL?
4.) What is the "official" way to link only some libraries statically?
Searching for lib*.a and add it to the link line looks like a hack to
me. I found libstdc++.a, but I did not find libgcc_s.a.
4.) My conclusion so far is that I should put
libstdc++.a -lnodefaultlibs -lc -lgcc_s
on the linker line.
The exe should run independent of the user's stdc++, because it has
its own statically linked. It has no code compiled in that makes it
depend on the GPL. It does depend on GLIBC (which I'm not allowed to
link statically) and on libgcc_s (which I did not manage to link
statically).
Thank you for your help.
Onno
|
|