From owner-freebsd-hackers Wed Sep 13 17:49:23 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from wall.polstra.com (rtrwan160.accessone.com [206.213.115.74]) by hub.freebsd.org (Postfix) with ESMTP id A9EE537B422 for ; Wed, 13 Sep 2000 17:49:20 -0700 (PDT) Received: from vashon.polstra.com (vashon.polstra.com [206.213.73.13]) by wall.polstra.com (8.9.3/8.9.3) with ESMTP id RAA29801; Wed, 13 Sep 2000 17:49:11 -0700 (PDT) (envelope-from jdp@polstra.com) From: John Polstra Received: (from jdp@localhost) by vashon.polstra.com (8.9.3/8.9.1) id RAA01334; Wed, 13 Sep 2000 17:49:11 -0700 (PDT) (envelope-from jdp@polstra.com) Date: Wed, 13 Sep 2000 17:49:11 -0700 (PDT) Message-Id: <200009140049.RAA01334@vashon.polstra.com> To: hackers@freebsd.org Cc: Janick.Taillandier@ratp.fr Subject: Re: Trouble with dynamic loading of C++ libs in PHP v4.02 on FreeBSD 4.1 In-Reply-To: <4F88710E19D4D311B36A00508B08FD0F2C84DA@nyplme11.neuilly.ratp> References: <4F88710E19D4D311B36A00508B08FD0F2C84DA@nyplme11.neuilly.ratp> Organization: Polstra & Co., Seattle, WA Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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 . > > If the library is called in a C program => no trouble. > If the library is called from PHP with the "dlopen()" function => > [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) = 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 -- John Polstra jdp@polstra.com John D. Polstra & Co., Inc. Seattle, Washington USA "Disappointment is a good sign of basic intelligence." -- Chögyam Trungpa To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message