From: CRDGW2::CRDGW2::MRGATE::"SMTP::PREP.AI.MIT.EDU::HELP-G++-REQUEST" 15-MAR-1992 09:25:14.04 To: ARISIA::EVERHART CC: Subj: Re: Building of shared C++ libraries on SunOS 4 From: help-g++-request@prep.ai.mit.edu@SMTP@CRDGW2 To: Everhart@Arisia@MRGATE Received: by crdgw1.ge.com (5.57/GE 1.123) id AA18652; Sun, 15 Mar 92 09:01:54 -0500 Received: by life.ai.mit.edu (4.1/AI-4.10) id AA10611; Sun, 15 Mar 92 07:34:31 EST Return-Path: Received: from news.cis.ohio-state.edu by life.ai.mit.edu (4.1/AI-4.10) id AB10602; Sun, 15 Mar 92 07:34:02 EST Received: by news.cis.ohio-state.edu (5.61-kk/5.911008) id AA26130; Sun, 15 Mar 92 07:27:39 -0500 Received: from USENET by news.cis.ohio-state.edu with netnews for help-g++@prep.ai.mit.edu (help-g++@prep.ai.mit.edu); contact usenet@news.cis.ohio-state.edu if you have questions. To: help-g++@prep.ai.mit.edu Date: 14 Mar 92 22:50:00 GMT Message-Id: Organization: Front End Oy, Espoo, Finland From: Teemu.Torma@frend.fi Sender: help-g++-request@prep.ai.mit.edu References: edu Subject: Re: Building of shared C++ libraries on SunOS 4 In article I wrote: I played a little bit with libg++ 2.0 and with couple of patches, succeeded of making a shared library out of it--at least "Hello World" compiles and executes ok. I was asked how to do it, so here is some information. Don't bother unless you know what you are doing. I did this on Sun SS1, SunOS 4.1.1. I have patch 100257-03 installed, and the library did not work with 100257-02 (dlsym did not find symbols in __do_dynamic_libs). I have no idea how this works on an unpatched system. 1) Only one patch is needed (to src/init.c, see below). 2) Compile the library and src/init.c with -fpic, and build a shared library using collect2 as the linker. I removed curses.o and CursesW.o to avoid linking with -lcurses. E.g. something like this. % make CC="gcc -fpic" ... now libg++.a should exist. % mkdir tmp % (cd tmp; ar x ../libg++.a; rm __.SYMDEF curses.o CursesW.o) % (cd src; gcc -fpic -g -c init.c -o ../tmp/init.o) % LIBDIR/ld -assert pure-text -o libg++.so.2.0 tmp/*.o -ldl ^^^^^^^^^ or whatever needed for collect2. Collect2 is used to generate ctor/dtor lists for the library, and -ldl since the runtime initialization will need it. 3) Compile src/drt0.c and put it into libg++.sa.2.0. Now you might want to try a "Hello World" program. If ldd reports that is uses libg++.2 and it's text size is only 8k, the library may even work. I don't know shared libraries well enough to say if this a really working library. I suppose some problems exist, otherwise the distribution would have rules to make the shared library. Teemu =========================================================================== --- src/init.c.~1~ Thu Aug 15 07:13:02 1991 +++ src/init.c Fri Mar 13 15:36:08 1992 @@ -60,7 +60,7 @@ off_ptr++; while( --i >= 0) { - fn = (void_fn)(((int)off_ptr) - ((int)(*off_ptr))); + fn = (void_fn)((int)(*off_ptr)); fn(); off_ptr++; } ===========================================================================