Project

Profile

Help

Bug #5876

closed

PHP-extension: Undefined symbol: xsltApplyStylesheet

Added by carlos juan about 1 year ago. Updated about 1 year ago.

Status:
Duplicate
Priority:
Low
Category:
PHP Build
Start date:
2023-02-09
Due date:
% Done:

0%

Estimated time:
Found in version:
12.0
Fixed in version:
Platforms:

Description

I'm trying to use Saxon-HE 12 with PHP 8 but after compiling and installing the extension, I'm getting an undefined symbol error.

The steps for installation are documented in the Dockerfile for the repository https://github.com/JuanKman94/saxon-he-php-demo

  • PHP version: PHP 8.1.15 (cli) (built: Jan 31 2023 15:13:17) (NTS gcc x86_64)
  • OS: Fedora 37
  • GLibC: 2.36
  • GCC: 12.2.1 20221121 (Red Hat 12.2.1-4)

SaxonC setup:

  • libsaxon-hec-12.0.so is installed in /lib64
  • PHP saxon.so extension is installed in /usr/lib64/php/modules

When looking for Saxon in the PHP config, this is the output (error included):

$ php -i | grep axon
PHP Warning:  PHP Startup: Unable to load dynamic library 'saxon' (tried: /usr/lib64/php/modules/saxon (/usr/lib64/php/modules/saxon: cannot open shared object file: No such file or directory), /usr/lib64/php/modules/saxon.so (/usr/lib64/php/modules/saxon.so: undefined
symbol: xsltApplyStylesheet)) in Unknown on line 0
/etc/php.d/20-saxon.ini,

Aside from that, the Dockerfile documents a change I had to made to the source code in order to compile it: sed -i 's|setRelocate|setRelocatable|g' php8_*.c*

In the repository's README there are instructions to troubleshoot the container, if additional data is needed, please let me know.


Related issues

Is duplicate of SaxonC - Bug #5868: C samples don't build with UbuntuClosedO'Neil Delpratt2023-02-03

Actions
Actions #1

Updated by O'Neil Delpratt about 1 year ago

On my linux box when I run the command I get the following output:

/etc/php/8.1/cli/conf.d/20-saxon.ini,
saxonc
saxonc => enabled
SaxonC API version => 12.0
PWD => /home/ond1/work/repository/saxondev-12/build/releases/libsaxon-HEC-linux-v12.0/samples/saxon-he-php-demo-main
OLDPWD => /home/ond1/work/repository/saxondev-12/build/releases/libsaxon-HEC-linux-v12.0/samples
$_SERVER['PWD'] => /home/ond1/work/repository/saxondev-12/build/releases/libsaxon-HEC-linux-v12.0/samples/saxon-he-php-demo-main
$_SERVER['OLDPWD'] => /home/ond1/work/repository/saxondev-12/build/releases/libsaxon-HEC-linux-v12.0/samples
Actions #2

Updated by O'Neil Delpratt about 1 year ago

I am running Ubuntu with PHP 8.1.11 (cli) (built: Sep 29 2022 22:29:14) (NTS)

I will try the docker image next.

Actions #3

Updated by O'Neil Delpratt about 1 year ago

Not getting any useful output when I run the php script

Actions #4

Updated by O'Neil Delpratt about 1 year ago

It was mentioned in bug issue #5856 that the libc6 is required by some systems. Please check if this is required for you too.

Actions #5

Updated by O'Neil Delpratt about 1 year ago

Also just to mention we have dropped the tracing flag argument in the setCatalog method. The following change is required in example.php:

$saxonProcessor->setCatalog(__DIR__ . '/catalog.xml');
Actions #6

Updated by O'Neil Delpratt about 1 year ago

I was able to reproduce the error using the docker image. In regards to comment #4 I tried with libc6 (glibc-devel) library, but still the same failure. My thinking now is we are failing to locate (link) the SaxonC library on the Fedora distribution.

In the docker script we copy the library with the command:

RUN cp libs/nix/libsaxon-hec-${SAXON_VER}.so /lib64

But not sure if PHP is picking this up.

Actions #7

Updated by O'Neil Delpratt about 1 year ago

  • Status changed from New to In Progress

I have managed to see why this is failing on on Fedora linux. In the C file SaxonCProcessor.c we have a reference to the function xsltApplyStylesheet which does not exist. It has been renamed to c_xsltApplyStylesheet. It is strange that this failure shows up on Fedora and not on Ubuntu where we run our tests. Given that the C API is not used in the PHP API you can workaround the problem by adding the following replace command in your Dockerfile:

RUN sed -i 's|return xsltApplyStylesheet(environi->thread, proc, cwd, source, stylesheet);|return 0;|g' SaxonCProcessor.c

This bug is related to the bug issue #5868, which I am still working on.

Actions #8

Updated by O'Neil Delpratt about 1 year ago

  • Related to Bug #5868: C samples don't build with Ubuntu added
Actions #9

Updated by carlos juan about 1 year ago

Hello, O'Neil

Thanks for all these details. At first I placed in libsaxon-hec-12.0.so in /usr/lib and the library wasn't being picked up but after placing it in /lib64 it changed the error from not finding the library to not finding the symbol.

As for the sed(1) command you shared, after running it before compiling and running php -i I no longer see a warning about not finding the symbol and see the expected output:

$ php -i | grep axon
/etc/php.d/20-saxon.ini,
saxonc
saxonc => enabled
SaxonC API version => 12.0
PWD => /opt/saxon/libsaxon-HEC-linux-v12.0/samples/php
OLDPWD => /opt/saxon/libsaxon-HEC-linux-v12.0/samples
$_SERVER['PWD'] => /opt/saxon/libsaxon-HEC-linux-v12.0/samples/php
$_SERVER['OLDPWD'] => /opt/saxon/libsaxon-HEC-linux-v12.0/samples

I tried running the example.php file from the repository and see an error but honestly that's not my file, it's part of the original repository I forked so I'm not worried about it. I did, however, run the tests from samples/php and only the tests that require a license fail, so I consider this a win.

I'm gonna try and use this newly compiled version in my project and if I run into another error, I'll be sure to open another issue as I think you've already sorted out this one by the sed(1) command.

Thanks and have a great weekend! Juan Carlos

Actions #10

Updated by O'Neil Delpratt about 1 year ago

  • Status changed from In Progress to Duplicate

Glad you overcame the issues. I am marking this issue as closed since it is a duplicate of the bug issue #5868 to do with the C API.

Actions #11

Updated by O'Neil Delpratt about 1 year ago

  • Is duplicate of Bug #5868: C samples don't build with Ubuntu added
Actions #12

Updated by O'Neil Delpratt about 1 year ago

  • Related to deleted (Bug #5868: C samples don't build with Ubuntu)

Please register to edit this issue

Also available in: Atom PDF