expat as a shared library

Brian Hurt bhurt at talkware.net
Mon Nov 15 22:47:36 GMT 1999

On Tue, 16 Nov 1999, Steve Ball wrote:

> Brian Hurt wrote:
> > 
> > I'm looking at building expat as a shared library (.so) on linux
> Building a shared library is quite easy.  TclExpat builds expat in the
> usual way, but adds the -PIC flag.  It then takes the object files and
> constructs the shared library.  The know-how on how to do that on various
> platforms is actually taken from the Tcl configuration, since Tcl is
> very good at determining which compile and link flags are ncessary.
> I can dig up some more specific details if you require.

Oh, how to do it was easy (see diff file at the end of this message).  I
was more wondering if this ground had been covered before and I was just
missing it.

Here's the diff.  It's short, so I hope I don't offend people by posting
it.  I haven't actually linked the output to anything yet, and you need to
put LDFLAGS=-shared on the make command line.  But I poked through the
resultant .so and things look good.

Index: Makefile
RCS file: /UTC1/cvsroot/utc/clib/expat/Makefile,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Makefile	1999/11/15 20:23:31	1.1
+++ Makefile	1999/11/15 22:30:20	1.2
@@ -16,6 +16,10 @@
   xmlparse/xmlparse.o \
   xmlparse/hashtable.o \
+LOBJS=xmltok/xmltok.o \
+  xmltok/xmlrole.o \
+  xmlparse/xmlparse.o \
+  xmlparse/hashtable.o
 all: xmlwf/xmlwf$(EXE)
@@ -23,8 +27,16 @@
 xmlwf/xmlwf$(EXE): $(OBJS)
 	$(CC) $(CFLAGS) -o $@ $(OBJS)
+libexpat.so: $(LOBJS)
+	$(LD) $(LDFLAGS) -o $@ $(LOBJS)
+	install -m 644 -g 0 -o 0 libexpat.so /usr/lib
+	install -m 644 -g 0 -o 0 xmltok/xmltok.h /usr/include
+	install -m 644 -g 0 -o 0 xmlparse/xmlparse.h /usr/include
-	rm -f $(OBJS) xmlwf/xmlwf$(EXE)
+	rm -f $(OBJS) xmlwf/xmlwf$(EXE) libexpat.so
 xmltok/nametab.h: gennmtab/gennmtab$(EXE)
 	rm -f $@

xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev at ic.ac.uk
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/ and on CD-ROM/ISBN 981-02-3594-1
To unsubscribe, mailto:majordomo at ic.ac.uk the following message;
unsubscribe xml-dev
To subscribe to the digests, mailto:majordomo at ic.ac.uk the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa at ic.ac.uk)

More information about the Xml-dev mailing list