tru64-unix-managers (formerly alpha-osf-managers) (1994-2012)
 help / color / mirror / Atom feed
From: Peyton Bland <bland@umich.edu>
Subject: SUMMARY: dynamic vs. shared executables
Date: Mon, 23 Jun 2003 15:41:44 -0400	[thread overview]
Message-ID: <p05200f04bb1d0487a187@[141.214.12.61]> (raw)

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@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@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@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@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.


                 reply	other threads:[~2003-06-23 19:41 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox