Hi,
Here's another late summary. My thanks to Joe, James, Lindsay, and
J.A. for their answers.
Peyton Bland
--------------
The original question:
Can someone clarify the difference between a "dynamic executable"
which is produced by ld when the -call_shared switch is given versus
a "shared executable" which is produced when the -shared switch is
given? (And if someone wants to answer a similar question for the
gcc compiler under Linux, I would appreciate it, but maybe it's the
same for gcc under Tru64... The man page says that -shared produces
a shared *library*, so I guess that wouldn't work if I need to
produce an executable...)
---------------
From: Joe Mario <mario_at_zk3.dec.com>
When you specify "-call_shared" during a link, an executable that will
use shared libraries is created. All executables of that kind of link
will link with the libc.so shared library at a minimum.
The "-call_shared" flag is the default for linking.
When you link with "-shared", you are creating a shared library.
---------------
From: James Sainsbury <J.Sainsbury_at_chem.usyd.edu.au>
I think the real difference is that -shared produces a position independent
shared object whereas the main program isn't or doesn't need to be.
Curiously the glibc runtime loader used in linux
(/lib/ld-linux.so.2-->/lib/ld-2.2.4)
is both a shared object and an executable.
(Try running /lib/ld-linux.so.2)
-----------------
From: "J.A. Gutierrez" <spd_at_shiva.cps.unizar.es>
You use "-call_shared" when you want to create an executable
which will use a shared library. In fact, when you use "cc"
with default options as a linker, it will call "ld -call_shared"
So, for instance:
cc -c hello.c
ld -o static_hello /usr/lib/cmplrs/cc/crt0.o hello.o -lc
will make a "static_hello" program which doesn't require
any shared library to run.
while
ld -o hello -call_shared /usr/lib/cmplrs/cc/crt0.o hello.o -lc
will make a "hello" which is a "dynamic executable" which
depends on /usr/shlib/libc.so, as you can see using "file"
and "ldd" commands.
(and, yes, you use "-shared" when you want to create lib*.so)
---------------------
From: "Wakeman, Lindsay" <Lindsay.Wakeman_at_bl.uk>
I was reading up on this issue a while back. As far as I understood
it (and I may be wrong..) the link loader produces
dynamically linked executables *by default*
The '-call_shared' flag is also available to specify this - but it isn't
actually needed.
The '-shared' flag produces dynamically shareable objects - i.e. that can
be used by other dynamically linked executables. This would be used to
produce shared library components for example.
The '-non-shared' flag produces static executables - i.e. no dynamic
linking.
Received on Mon Jun 23 2003 - 19:42:27 NZST