From owner-freebsd-hackers Thu Sep 14 8:29:40 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from ns.yogotech.com (ns.yogotech.com [206.127.123.66]) by hub.freebsd.org (Postfix) with ESMTP id A9B3637B43C for ; Thu, 14 Sep 2000 08:29:36 -0700 (PDT) Received: from nomad.yogotech.com (nomad.yogotech.com [206.127.123.131]) by ns.yogotech.com (8.9.3/8.9.3) with ESMTP id JAA03629; Thu, 14 Sep 2000 09:29:35 -0600 (MDT) (envelope-from nate@nomad.yogotech.com) Received: (from nate@localhost) by nomad.yogotech.com (8.8.8/8.8.8) id JAA17389; Thu, 14 Sep 2000 09:29:34 -0600 (MDT) (envelope-from nate) Date: Thu, 14 Sep 2000 09:29:34 -0600 (MDT) Message-Id: <200009141529.JAA17389@nomad.yogotech.com> From: Nate Williams MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable To: John Polstra Cc: hackers@FreeBSD.ORG, Janick.Taillandier@ratp.fr Subject: Re: Trouble with dynamic loading of C++ libs in PHP v4.02 on FreeBSD 4.1 In-Reply-To: <200009140049.RAA01334@vashon.polstra.com> References: <4F88710E19D4D311B36A00508B08FD0F2C84DA@nyplme11.neuilly.ratp> <200009140049.RAA01334@vashon.polstra.com> X-Mailer: VM 6.34 under 19.16 "Lille" XEmacs Lucid Reply-To: nate@yogotech.com (Nate Williams) Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > > We are trying to create a dynamic library of extensions to PHP 4.02= . > > This library implements a C++ class and has a C interface using the= "Extern C" > > declaration. > > This library is linked with libstdc++.so.3 . > >=20 > > If the library is called in a C program =3D> no trouble. > > If the library is called from PHP with the "dlopen()" function =3D>= > > [Warning: Unable to load dynamic library > > '/users/em/ftp/php/test_cpp/debug/libphptest.so' - /usr/lib/libstdc= ++.so.3: > > Undefined symbol "__ti9exception" in > > /usr/local/httpd/htdocs/www/Iti_q/testso.php on line 2 >=20 > This is because FreeBSD uses an archive library "libgcc.a" instead > of a shared library. That means that everything from libgcc which > is needed by your shared libraries had better already be linked into > the main program. The right solution is for us to use a shared > library for libgcc. At one point libgcc was shared (FreeBSD 1.*), and it caused way more problems that it solved. Nate (Note to eager committers: don't do this without > coordinating with obrien. There are ramifications that aren't > obvious.) >=20 > As a work-around, try adding this to your main program. (I am > assuming it is a C++ program too.) >=20 > extern void terminate(void); > void (*kludge_city)(void) =3D terminate; >=20 > Another possibility would be to link explicitly with libgcc when > creating your dynamic library: >=20 > cc -shared -o libphptest.so ... -lgcc >=20 > That might cause other problems, but probably not. >=20 > John > --=20 > John Polstra jdp@pols= tra.com > John D. Polstra & Co., Inc. Seattle, Washing= ton USA > "Disappointment is a good sign of basic intelligence." -- Ch=F6gya= m Trungpa >=20 >=20 >=20 > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-hackers" in the body of the message To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message