*BSD News Article 93850


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!news.cs.su.oz.au!metro!metro!munnari.OZ.AU!news.mel.connect.com.au!news.mel.aone.net.au!news-out.internetmci.com!newsfeed.internetmci.com!usenet.logical.net!news.mathworks.com!news.maxwell.syr.edu!news.visi.net!news.infi.net!news.infi.net!not-for-mail
From: neilr@richmond.infi.net (Robert Neil)
Newsgroups: comp.unix.bsd.openbsd.misc
Subject: Re: Dll in Unix
Date: Thu, 17 Apr 1997 19:55:36 GMT
Organization: InfiNet
Lines: 49
Message-ID: <335668f9.1025674@news.richmond.infi.net>
References: <3354db72.562926@noticias.ibernet.es>
NNTP-Posting-Host: pm4-190.richmond.infi.net
X-Newsreader: Forte Agent .99e/32.227
Xref: euryale.cc.adfa.oz.au comp.unix.bsd.openbsd.misc:64

lterroba@mail.comunet.es (Luis Felipe Terroba Gumiel) wrote:

>>> Could anybody tell me how to create and use Dll in Unix? Thanks.

For a.out format executables this works.  For ELF format, things are
different (and much better).

The following makefile was used to build both static and shared
versions of the library:

CC=gcc
CCARGS= -c -D_POSIX_SOURCE
LIBCCARGS= -c -D_POSIX_SOURCE
SHLIBCCARGS= -c -D_POSIX_SOURCE -DPIC -fpic

all:

        # Compile the processes
        ${CC} ${CCARGS} process1.c
        ${CC} ${CCARGS} process2.c

        # Build the shared library
        ${CC} ${SHLIBCCARGS} libfile1.c
        ${CC} ${SHLIBCCARGS} libfile2.c
        ar cq libx_pic.a `lorder libfile1.o libfile2.o | tsort`
        ranlib libx_pic.a
        ld -x -Bshareable -Bforcearchive -o libx.so.1.0 libx_pic.a
        rm libfile1.o
        rm libfile2.o

        # Link the shared library versions of the executables
        ${CC} -o process1s process1.o libx.so.1.0
        ${CC} -o process2s process2.o libx.so.1.0

        # Build the static library
        ${CC} ${LIBCCARGS} libfile1.c
        ${CC} ${LIBCCARGS} libfile2.c

        ar r libx.a libfile1.o libfile2.o

        # Build the static versions of the executables
        ${CC} -static -o process1ns process1.o libx.a
        ${CC} -static -o process2ns process2.o libx.a

-----
Robert Neil
neilr@richmond.infi.net
phone 407-255-0534
fax   407-259-6872 (include my name and phone # on cover sheet)