From owner-freebsd-hackers Fri Sep 15 7:40:45 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from tistix.ratp.fr (tistix.ratp.fr [62.160.169.66]) by hub.freebsd.org (Postfix) with ESMTP id 3C55837B423 for ; Fri, 15 Sep 2000 07:40:42 -0700 (PDT) Received: from nyplic12.neuilly.ratp (mail.ratp.fr [62.160.169.132]) by tistix.ratp.fr with ESMTP id QAA72403 ; Fri, 15 Sep 2000 16:40:01 +0200 (DST) From: Received: by nyplic12.neuilly.ratp with Internet Mail Service (5.5.2650.21) id ; Fri, 15 Sep 2000 16:41:24 +0100 Message-ID: <4F88710E19D4D311B36A00508B08FD0F2C84F6@nyplme11.neuilly.ratp> To: jdp@polstra.com, hackers@freebsd.org Subject: RE: Trouble with dynamic loading of C++ libs in PHP v4.02 on Free BSD 4.1 Date: Fri, 15 Sep 2000 16:41:20 +0100 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2650.21) Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Thank you John! Linking the library with -lgcc solved the problem. In article = <4F88710E19D4D311B36A00508B08FD0F2C84DA@nyplme11.neuilly.ratp>, wrote: > 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 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. (Note to eager committers: don't do this without coordinating with obrien. There are ramifications that aren't obvious.) As a work-around, try adding this to your main program. (I am assuming it is a C++ program too.) extern void terminate(void); void (*kludge_city)(void) =3D terminate; Another possibility would be to link explicitly with libgcc when creating your dynamic library: cc -shared -o libphptest.so ... -lgcc That might cause other problems, but probably not. John --=20 John Polstra = jdp@polstra.com John D. Polstra & Co., Inc. Seattle, = Washington USA "Disappointment is a good sign of basic intelligence." -- Ch=F6gyam = Trungpa To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message