From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,220df4960136f4bc X-Google-Attributes: gidfee84,public From: Tim Lucia Subject: Re: Creating Shared Libraries Date: 1997/02/12 Message-ID: <330247B9.33FA@zko.dec.com>#1/1 X-Deja-AN: 218809547 References: <5dfpaa$k22@missun.cus.cul.ca> To: Christopher Yap Content-Type: text/plain; charset=us-ascii Organization: Digital Equipment Corporation, Digital Ladebug Debugger Mime-Version: 1.0 Newsgroups: comp.unix.osf.osf1 X-Mailer: Mozilla 3.0 (X11; I; OSF1 V3.2 alpha) Makefile: # # Simple example of how to build a shared library on Digital UNIX(tm). # Written by: Timothy J. Lucia, lucia@zko.dec.com # # Don't forget to set LD_LIBRARY_PATH to the cwd (.) before running # the main program. In the K-shell, this is done via: # # $ export LD_LIBRARY_PATH=. # # and in the C-shell: # # % setenv LD_LIBRARY_PATH . # DEBUGFLAGS = -g -O0 CCFLAGS = $(DEBUGFLAGS) CC = cc $(CCFLAGS) LDFLAGS = $(DEBUGFLAGS) LD = ld $(LDFLAGS) RM = rm -f all: main library.so main: main.o library.so $(CC) -o main main.o library.so main.o: main.c $(CC) -c main.c library.so: library.o $(LD) -shared -o library.so library.o -lc library.o: library.c $(CC) -c library.c clean: $(RM) main main.o library.o library.so so_locations library.c: #include void bar(void) { printf("Inside shared library:bar()\n"); } main.c: #include void main(void) { extern void bar(void); printf("Inside of main\n"); bar(); } ~/example> make CC=gcc gcc -c main.c gcc -c library.c ld -g -O0 -shared -o library.so library.o -lc gcc -o main main.o library.so ~/example> ./main Inside of main Inside shared library:bar() ~/example> Enjoy! Tim -- Timothy J. Lucia Digital Ladebug Debugger Developer Digital Equipment Corporation Cat IV Charter/Banyan/Wheelworks/NEBC 110 Spitbrook Road ZK2-3Q08 Email: lucia@zko.dec.com Nashua, NH USA 03062-2698 603.881.2615(Voice)/603.881.0120(FAX)