From owner-freebsd-questions Sun Jun 23 18:15:12 1996 Return-Path: owner-questions Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id SAA09347 for questions-outgoing; Sun, 23 Jun 1996 18:15:12 -0700 (PDT) Received: from jolt.eng.umd.edu (jolt.eng.umd.edu [129.2.102.5]) by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id SAA09341 for ; Sun, 23 Jun 1996 18:15:10 -0700 (PDT) Received: from ginger.eng.umd.edu (ginger.eng.umd.edu [129.2.98.204]) by jolt.eng.umd.edu (8.7.5/8.7.3) with ESMTP id VAA12717; Sun, 23 Jun 1996 21:15:09 -0400 (EDT) Received: (from chuckr@localhost) by ginger.eng.umd.edu (8.7.5/8.7.3) id VAA10772; Sun, 23 Jun 1996 21:15:08 -0400 (EDT) Date: Sun, 23 Jun 1996 21:15:07 -0400 (EDT) From: Chuck Robey X-Sender: chuckr@ginger.eng.umd.edu To: Andrew Herdman cc: questions@freebsd.org Subject: Re: Creating a true static binary In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-questions@freebsd.org X-Loop: FreeBSD.org Precedence: bulk On Sun, 23 Jun 1996, Andrew Herdman wrote: > On Sun, 23 Jun 1996, Chuck Robey wrote: > > > On Sun, 23 Jun 1996, Andrew Herdman wrote: > > > > > I've noticed that whenever I create a static binary for people, that libc > > > is never included (perhaps others as well?) in the binary. This started > > > becomming a problem when I moved up to 2.2-960501-SNAP where libc changed > > > from 2.2 to 3.0. Is there a way to have the binary include everything it > > > needs into itself so that no libraries are necessary? > > > > Realize that doing what you ask is going to create huge binaries, but I > > guess that's your lookout ... just link your program with the -static > > option (check the gcc man page). > > Yes I know the binaries will be huge, even without libc they are huge > (thanks to motif) I've tried -static with no luck, my associates who have > gotten the binaries I have created have reported that they complained > about the missing libc.so.3.0, but they didn't complain about any missing > motif libraries. The ldd command is used to scan executeables, and reports what libs they are linked to. If you compile with the -static flag in cflags, then an ldd done on the resulting executeables should give you the error that you have not created a dynamic executeable. If it does this, then you can look to a mistake that your associates have made, because you HAVE made a standalone executeable. Dynamic executables have a file 'ld.so' prepended to them, which is a smallish binary that actually handles going out and getting the libs, when the program starts up. A program linked statically doesn't have this (always at the start of the executeable). You could verify this using the nm command, doing 'nm -n '. If it's a shared executeable, then the first symbols you'll see are dlopen, dl.... If you don't see these at the start of the nm listing (pipe it into less, it'll be huge) then, again, you can be sure you DON'T have a shared executeable. These are the best checks that come to mind. If it passes these, then you can go looking at your associate's environments, because that's causing the problem. Make SURE they're really executing your binary, not something else in the path. ----------------------------+----------------------------------------------- Chuck Robey | Interests include any kind of voice or data chuckr@eng.umd.edu | communications topic, C programming, and Unix. 9120 Edmonston Ct #302 | Greenbelt, MD 20770 | I run Journey2 and n3lxx, both FreeBSD (301) 220-2114 | version 2.2 current -- and great FUN! ----------------------------+-----------------------------------------------