jeremy@eik.ii.uib.no (Jeremy Cook) (11/30/90)
I thought why not try to get shared libraries working with motif (motif 1.1 on SPARCStation running SunOS4.1). Well I managed to get it to work but need some help to get it to be totally user transparent. Carry out the following: o patch lib/Xm/Imakefile to generate shared library targets using the following diff *** Imakefile.orig Tue Nov 20 12:10:29 1990 --- Imakefile Tue Nov 20 12:34:16 1990 *************** *** 180,186 **** --- 180,195 ---- OBJS = $(OBJS1) $(OBJS2) + /* Trying with shared libraries -- JMC 20/11-90 */ + /* (using Xt's rev) */ + #if SharedLibXt + SharedLibraryObjectRule() + NormalSharedLibraryTarget(Xm,$(SOXTREV),$(OBJS)) + InstallSharedLibrary(Xm,$(SOXTREV),$(USRLIBDIR)) + #else NormalLibraryObjectRule() + #endif + NormalLibraryTarget(Xm,$(OBJS)) LintLibraryTarget(Xm,$(SRCS)) (Note that I didn't bother making a special version number for Xm, I used Xt's) o build all the object files: make Makefile ; make o After a very long time this halts with the following text: rm -f libXm.so.4.0~ (cd shared; ld -o ../libXm.so.4.0~ -assert pure-text ArrowB.o ArrowBG.o ArrowB I.o BulletinB.o CascadeB.o CascadeBG.o Command.o CutPaste.o DialogS.o Dra wingA.o DrawnB.o FileSB.o Form.o Frame.o Gadget.o GadgetUtil.o GeoUtil s.o HeapMgr.o ImageCache.o Label.o LabelG.o List.o MainW.o MapEvents.o M enuShell.o MenuUtil.o MessageB.o NavigMap.o PanedW.o PushB.o PushBG.o Read Image.o ResConvert.o ResInd.o RowColumn.o Sash.o Scale.o ScrollBar.o S crolledW.o SelectioB.o SeparatoG.o Separator.o Simple.o Text.o TextIn.o T extOut.o TextStrSrc.o ToggleB.o ToggleBG.o ToggleBI.o UniqueEvnt.o VaSimpl e.o Visual.o XmString.o TextF.o AtomMgr.o Cache.o GetSecRes.o TrackLoc.o Protocols.o Primitive.o Manager.o Traversal.o Dest.o Vendor.o VendorE.o E xtObject.o BaseClass.o VirtKeys.o Desktop.o) ld: GLOBAL_OFFSET_TABLE overflown: need to use -PIC *** Error code 4 make: Fatal error: Command failed for target `libXm.so.4.0' o I do not know what 'GLOBAL_OFFSET_TABLE overflown' really means but I get the impression that some internal limit is being exceeded and ld refuses to behave ("need to use -PIC" is merely a red herring). o It is however a simple matter to manually build *two* libraries instead: cd shared ld -o libXm-a.so.4.0 -assert pure-text [A-R]*.o ld -o libXm-b.so.4.0 -assert pure-text [S-Z]*.o o This builds two shared libraries of about 0.5Mbytes each and ld is happy. Copying these to the appropriate dir and linking your application using -lXm-a -lXm-b *instead* of -lXm means that your application will now use shared motif libraries! ldd application -lXm-a.4 => /lib/libXm-a.so.4.0 -lXm-b.4 => /lib/libXm-b.so.4.0 -lXt.4 => /lib/libXt.so.4.0 -lX11.4 => /lib/libX11.so.4.3 -lc.1 => /lib/libc.so.1.5 strip application ls -l application -rwxr-xr-x 1 jeremy 24576 Nov 21 10:59 application o It seems to work ok, but I have only tested with relatively simple applications. It could break at any moment. It would be useful if someone can tell me how to build a BIG shared library out of the two pieces that I have, I would be most grateful. Jeremy Cook email : jeremy@eik.ii.uib.no