Errors Compiling PHP with Sablotron

Posted in PHP -

The Electric Toolbox website uses the Sablotron and Expat libraries to convert XML to XSL. These extensions are very fast at running these XSL transformations and are available for download from The Ginger Alliance (Sablotron) and Sourceforge (Expat).

To compile Sablotron into PHP you must first compile Expat and Sablotron. When compiling PHP, add the --enable-xslt and --with-xslt-sablot flags. Note that you should not use Expat version 1.95.6 as it is broken and will not work; use 1.95.5 instead.

When I first attempted to compile these extensions into PHP I kept getting the same errors (I'm not sure which version of PHP I first had this problem with, or whether it is still a problem), which are as follows:

/usr/local/lib/libsablot.so: undefined reference to `operator new[](unsigned)'
/usr/local/lib/libsablot.so: undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
/usr/local/lib/libsablot.so: undefined reference to `operator delete(void*)'
/usr/local/lib/libsablot.so: undefined reference to `__gxx_personality_v0'
/usr/local/lib/libsablot.so: undefined reference to `__cxa_pure_virtual'
/usr/local/lib/libsablot.so: undefined reference to `vtable for __cxxabiv1::__class_type_info'
/usr/local/lib/libsablot.so: undefined reference to `operator delete[](void*)'
/usr/local/lib/libsablot.so: undefined reference to `vtable for __cxxabiv1::__vmi_class_type_info'
/usr/local/lib/libsablot.so: undefined reference to `operator new(unsigned)'
collect2: ld returned 1 exit status
make: *** [sapi/cgi/php] Error 1

To fix this problem you need to modify the Makefile after running the PHP configure script. If you have already run "make" and got the error above, you'll need to run "make clean" otherwise you'll end up with the same problem.

Open up the Makefile in your favorite text editor and locate the line labelled "EXTRA_LDFLAGS". It will look something like so (not the directory locations may not be exactly the same and you may have more or less flags depending on what other modules you are compiling in):

EXTRA_LDFLAGS = -avoid-version -module -L/usr/local/lib -L/usr/lib/mysql

Modify the line to have "-lstdc++" at the end. It will now look similar to:

EXTRA_LDFLAGS = -avoid-version -module -L/usr/local/lib -L/usr/lib/mysql -lstdc++

Now run make and you should be fine. If you still have the same problem, add -lstdc++ to the end of the EXTRA_LIBS line which is a couple of lines below the EXTRA_LDFLAGS in the makefile like in the following example:

EXTRA_LIBS = -lcrypt -lc-client -lsablot -lexpat -lcrypt -lpq -lpdf -lz -lpng -ljpeg -lmysqlclient -lcrypt -lpam -lt1 -lfreetype -lpng -lz -ljpeg -lz -lresolv -lm -ldl -lnsl -lcrypt -lcrypt -lstdc++


Comments