Date: Thu, 25 Apr 1996 16:07:59 -0700 (MST) From: Terry Lambert <terry@lambert.org> To: hoppy@appsmiths.com (Hoppy) Cc: freebsd-questions@freebsd.org Subject: Re: recipe for shared libraries? Message-ID: <199604252307.QAA25747@phaeton.artisoft.com> In-Reply-To: <Pine.BSF.3.91.960425135956.8982B-100000@anvil.appsmiths.com> from "Hoppy" at Apr 25, 96 02:03:12 pm
next in thread | previous in thread | raw e-mail | index | archive | help
> 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 <bsd.lib.mk> == 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.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199604252307.QAA25747>