Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
From: Tim Lucia <lucia@zko.dec.com>
To: Christopher Yap <cyap@monet.esys.ca>
Subject: Re: Creating Shared Libraries
Date: 1997/02/12	[thread overview]
Message-ID: <330247B9.33FA@zko.dec.com> (raw)
In-Reply-To: 5dfpaa$k22@missun.cus.cul.ca


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 <stdio.h>

void bar(void)
{
    printf("Inside shared library:bar()\n");
}



main.c:
#include <stdio.h>

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)



  parent reply	other threads:[~1997-02-12  5:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-02-07  5:00 Creating Shared Libraries Christopher Yap
1997-02-08  5:00 ` Graham Jones
1997-02-12  5:00 ` Tim Lucia [this message]
  -- strict thread matches above, loose matches on Subject: below --
1995-12-12  5:00 Creating shared libraries Scott Tringali
1995-12-13  5:00 ` Jochen Klein
1995-12-15  5:00 ` Tim Lucia
1995-12-18  5:00   ` Tim Lucia
1995-12-18  5:00     ` Tim Lucia
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