Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!cs.utexas.edu!uwm.edu!spool.mu.edu!snorkelwacker.mit.edu!bloom-picayune.mit.edu!athena.mit.edu!lwvanels From: lwvanels@athena.mit.edu (Lucien W. Van Elsen) Newsgroups: comp.unix.aix Subject: Re: Shared libraries Keywords: shared libraries Message-ID: <1991Jun27.120648.3352@athena.mit.edu> Date: 27 Jun 91 12:06:48 GMT References: Sender: news@athena.mit.edu (News system) Distribution: comp Organization: Massachusetts Institute of Technology Lines: 44 In article , schaf@socrates.ucsf.edu (Chris Schafmeister%Kollman) writes: |> I am working on a program that uses X11R4 on the RS6000 |> and I want to distribute the program to other RS6000s without |> having to move the X11R4 libraries with it. When |> I tried to link with '-bnoautoimp' the linker had a fit |> telling me that it could not link standard library routines like |> 'open', 'close' etc. |> |> Thanks in advance. Note- this information is from experimentation; I havn't found a definitive reference on any of this yet (although I would very much appreciate hearing from anyone who has!) In order to link a shared library statically, you need to give an explicit path -L to the library, and provide whatever imports the library needs to resolve. For example, to link 'foo.o' with a non-shared version of the C library, you'd use: cc -o foo -bnso foo.o -bimport:/lib/syscalls.exp -L/lib -lc It is also possible to re-link an executable to use static libraries instead of shared. You need to again explicitly specify any imports the library expects to find, as well as an explicit -L path to the library. For example: godtree /tmp) cat > foo.c main() { printf("Hello, world.\n"); } splat /tmp) cc -o foo foo.c splat /tmp) ls -l foo -rwxr-xr-x 1 lwvanels usr 3158 May 23 13:30 foo* splat /tmp) cc -o foo.new -bnso -bimport:/lib/syscalls.exp foo -L/lib splat /tmp) ls -l foo.new -rwxr-xr-x 1 lwvanels usr 223147 May 23 13:31 foo.new* splat /tmp) ./foo Hello, world. -- Lucien Van Elsen MIT Athena Systems Development