From owner-freebsd-questions Thu Apr 25 16:13:33 1996 Return-Path: owner-questions Received: (from root@localhost) by freefall.freebsd.org (8.7.3/8.7.3) id QAA18714 for questions-outgoing; Thu, 25 Apr 1996 16:13:33 -0700 (PDT) Received: from phaeton.artisoft.com (phaeton.Artisoft.COM [198.17.250.211]) by freefall.freebsd.org (8.7.3/8.7.3) with SMTP id QAA18705 for ; Thu, 25 Apr 1996 16:13:30 -0700 (PDT) Received: (from terry@localhost) by phaeton.artisoft.com (8.6.11/8.6.9) id QAA25747; Thu, 25 Apr 1996 16:07:59 -0700 From: Terry Lambert Message-Id: <199604252307.QAA25747@phaeton.artisoft.com> Subject: Re: recipe for shared libraries? To: hoppy@appsmiths.com (Hoppy) Date: Thu, 25 Apr 1996 16:07:59 -0700 (MST) Cc: freebsd-questions@freebsd.org In-Reply-To: from "Hoppy" at Apr 25, 96 02:03:12 pm X-Mailer: ELM [version 2.4 PL24] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-questions@freebsd.org X-Loop: FreeBSD.org Precedence: bulk > I'm trying to construct a shared library using g++, but I apparently don't > have the whole dance quite right. > > I end up with 'ld.so failed' > > I'm compiling with 'g++ -fpic ...', linking with 'ld -Bshareable' and > getting a *.so.2.1 file, which I place somewhere where ldconfig > discovers it at boot (ldconfig -r reports it). > > How can I further troubleshoot this. 1) You *must* use BSD makefiles, or you *must* explicitly link with c++rt0.o. 2) If you use BSD makefiles, you can do something like: == Makefile: BEGIN ========================================================== # Library to create (xxx = make libxxx.s0.MMM.mmm # LIB = xxx # Major version number (MMM in comment, above) # SHLIB_MAJOR= 3 # Minor version number (mmm in comment, above) # SHLIB_MINOR= 0 # Needed if you are makeing a c++ library (constructors, destructors, etc.) # CPLUSPLUSLIB=YES # List of source files # SRCS = mysource.c # Additions to CFLAGS. These one say "include local headers as if they # were system headers and whine about what might just be grammatical # or style differences between me and the authors of GCC" # CFLAGS += -I. -I${.CURDIR} -Wall -ansi -pedantic # define if you need to use libraries with this library; like the lex lib # # LDFLAGS += -ll # define if you need to remove generated source (yacc, lex, etc) # # CLEANFILES+= lex.c parser.c y.tab.h # Define this target for things to do before doing the default library # installation rules; in this example, we have header files that go # with the library that we want to be installed so the library is usable; # if they aren't there, we don't want to install the library (there's # also "afterinstall", etc... see /usr/share/mk/bsd.README and the # "man make" page). # # beforeinstall: # @(cd ${.CURDIR}; cmp -s forms.h ${DESTDIR}/usr/include/forms.h || \ # install -c -o ${BINOWN} -g ${BINGRP} -m 444 forms.h \ # ${DESTDIR}/usr/include/forms.h;) # Must do this to get the BSD specific rules for libraries. # .include == Makefile: END ============================================================ 3) If you don't use BSD makefiles You should be shot. 8-). Terry Lambert terry@lambert.org --- Any opinions in this posting are my own and not those of my present or previous employers.