Creating a statically linked executable

Creating a statically linked executable

Post by Phil Howa » Tue, 21 Jul 1998 04:00:00



I see discussion on creating a static library.  How can I create a statically
linked executable?  Is this possible using shared libraries as the source for
the code to be linked, but copies the code into the executeable so it can run
even if the shared library is absent (and would obviously not shared memory
with the code from the shared library that is present)?

--
 --    *-----------------------------*      Phil Howard KA9WGN       *    --
  --   | Inturnet, Inc.              | Director of Internet Services |   --
   --  | Business Internet Solutions |       eng at intur.net        |  --
    -- *-----------------------------*      philh at intur.net       * --

 
 
 

Creating a statically linked executable

Post by Eric Thompso » Tue, 21 Jul 1998 04:00:00


How can I create a statically
Quote:> linked executable?

just replace the -shared/-dynamic option to gcc with -static
 Is this possible using shared libraries as the source for
Quote:> the code to be linked, but copies the code into the executeable so it can run
> even if the shared library is absent (and would obviously not shared memory
> with the code from the shared library that is present)?

yes, as far as I know it puts all the code needed in your executable.
this of course makes the exe much bigger and the compile time longer.

 
 
 

1. problems creating a statically bound executable

Hi,
I tried to create a static version of bash (as it was discussed elsewhere) as
a /bin/sh replacement.
I simply changed -Bdynamic to -Bstatic in the makefile, but then I get
errors, that some libraries where not found. E.g a /usr/lib/libdl.a is missing.
As this seems to be a part of the dynamic linker I would have a problem if
it doesn't exist. But deleting -ldl from the library list gives an error,
that symbols like dlopen, dlclose are missing, but from /usr/lib/libc.a!!!??

When testing other programs to link statically I have same or similar problems.
Additionally /bin/file doesn't seem to be able to distinguish between static and
Dynamic bound executables.

Can someone help me?
Thomas
---
Thomas Krebs
Department for Manufacturing Automation and Production Systems FAPS
University of Erlangen
Egerlandstr. 7-9
91058 Erlangen
Tel.: +49 (0)9131/85-8740
Fax:  +49 (0)9131/302528
http://www.faps.uni-erlangen.de:1200/persons/krebs.html

2. scaleable chat server

3. Question about statically linked executable, glibc and LGPL

4. Repost: AWE32 problem in RedHat 7.0 HELP!!!

5. Make statically-linked executable from dynamic, with no source ?

6. ??: compressed FAT32 partition mountable with Linux ?

7. How to build statically linked executable on Solaris with g++?

8. Good, inexpensive laser printer -- any recommendations?

9. executable with shared lib vs statically linked

10. making statically-linked executable

11. Building a statically linked executable

12. Problems creating tiny, statically linked application

13. Converting Dynamicly linked programs to statically linked...how?