iliaal / php_excel

PHP Extension interface to the Excel writing/reading library
http://ilia.ws
533 stars 131 forks source link

php 8 libxl.so not finding xlCreateBookCA in -lxl #267

Closed do-io closed 3 years ago

do-io commented 3 years ago
#5 15.74 checking for excel includes... found in /tmp/libxl-3.9.4.3/include_c/
#5 15.74 checking for excel libraries... found in /tmp/libxl-3.9.4.3/lib64/
#5 15.74 checking for libxml2... found in /usr/include/libxml2
#5 15.74 checking for xlCreateBookCA in -lxl... configure: error: excel module requires libxl >= 2.4.3

running ./configure after phpize, I get the same error no matter the version of libxl downloaded.

@Jan-E - might you have an idea concerning this? Might you need more information?

FROM php:8-fpm-alpine3.13

RUN \
# Install dependencies
    apk add --no-cache autoconf build-base gnupg nginx php8-gd php8-json \
        php-opcache php-pdo_mysql tzdata s6-overlay wget git libxml2-dev \
    && apk upgrade --no-cache \
# Remove some default NGINX config
    && rm -f /etc/nginx.conf \
        /etc/nginx/http.d/default.conf \
        /etc/php8/php-fpm.d/www.conf \
    && rm -rf /etc/nginx/sites-* \
# nginx logs written to stderr
    && ln -s /dev/stderr /var/log/nginx/error.log \
# Install libxl-3.9.4.3
#    && export GNUPGHOME="$(mkdtemp -d)" \
    && cd /tmp \
    && pwd \
    && ls -la \
    && wget http://www.libxl.com/download/libxl-lin-3.9.4.3.tar.gz \
    && tar -zxv -f libxl-lin-3.9.4.3.tar.gz --directory /tmp/ \
    && ls -la \
    && cd /tmp/libxl-3.9.4.3/ \
    && mkdir -p /usr/local/libxl \
    && ls -la /tmp/libxl-* \
    && cp -r /tmp/libxl-3.9.4.3/* /usr/local/libxl \
    && ls -la /usr/local/libxl \

# Install php_excel
    && docker-php-source extract \
    && docker-php-ext-install xml \
    && cd /tmp \
    && git clone https://github.com/Jan-E/php_excel.git -b php7_with_pulls \
    && cd /tmp/php_excel \
    && pwd && ls -la \
    && phpize \
    && ./configure \
        --with-php-config=$(which php-config) \
        --with-libxl-incdir=/tmp/libxl-3.9.4.3/include_c/ \
        --with-libxl-libdir=/tmp/libxl-3.9.4.3/lib64/ \
        --with-excel=/usr/local/libxl \
        --with-libxml-dir=/usr/include/libxml2
    && make \
    && cp /tmp/php_excel/modules/excel.so \
        /usr/local/lib/php/extensions/no-debug-non-zts-20190902/ \
    && cp /tmp/libxl-3.9.4.3/lib64/libxl.so /usr/lib/libxl.so

COPY src/ /var/www

RUN \
# run s6 as a non-root user
    mkdir -p /etc/s6/services/nginx/supervise /etc/s6/services/php-fpm8/supervise \
    && mkfifo \
        /etc/s6/services/nginx/supervise/control \
        /etc/s6/services/php-fpm8/supervise/control \
    && chown -R 65534:82 /etc/s6 /run /var/lib/nginx /var/www \
#    && chown -R 65534:82 /etc/s6 /run /srv/* /var/lib/nginx /var/www \
    && chmod o+rwx /run /var/lib/nginx /var/lib/nginx/tmp \
# Clean up
    && rm -rf "${GNUPGHOME}" /tmp/* \
    && apk del gnupg

COPY etc/ /etc/

WORKDIR /var/www

# user nobody , group www-data
USER 65534:82
Jan-E commented 3 years ago

Try setting LIBS: https://github.com/iliaal/php_excel/issues/21#issuecomment-3218478

Jan-E commented 3 years ago

I ran into the same error with libxl-3.9.4.3. Setting LIBS did not work. Compilation worked fine with libxl-3.8.4.0 You can still download that version: https://www.libxl.com/download/libxl-lin-3.8.4.tar.gz

Somehow the check for xlCreateBookCA fails with the newest version. There is no mention of changes in the changelog.txt.

You can trick the compilation to go all the way with libxl-3.9.4.3 by changing ac_cv_lib_xl_xlCreateBookCA=no into ac_cv_lib_xl_xlCreateBookCA=yes in the generated configure

Jan-E commented 3 years ago

When I tried to load the excel.so with libxl-3.9.4.3 on my old CentOS 6 system, I got this error:

versionGLIBC_2.14' not found (required by /usr/local/src/libxl-3.9.4.3/lib64/libxl.so`

That might also be the cause of the failing test for xlCreateBookCA!

Jan-E commented 3 years ago

I am running Glibc 2.12 on the CentOS 6 system:

# ldd --version
ldd (GNU libc) 2.12

@do-io What is your version?

Jan-E commented 3 years ago

Building and loading with this ftp://xlware.com/build/libxl-lin-3.9.0.5.tar.gz (found at ftp://xlware.com/build ) worked fine. Maybe there are newer 3.9.x versions that also work, but at least this one did.

Jan-E commented 3 years ago

https://www.libxl.com/download/libxl-lin-3.9.3.0.tar.gz still works. https://www.libxl.com/download/libxl-lin-3.9.4.2.tar.gz does not. https://www.libxl.com/download/libxl-lin-3.9.4.3.tar.gz does not.

Apparently the 3.9.4.x versions were compiled on a platform with a Glibc > 2.12

do-io commented 3 years ago

@Jan-E it looks like the php8 alpine docker image I am installing installed with glib (2.66.8-r0). Going to flip to another PHP image to see what we had with the regular apache debian image

Jan-E commented 3 years ago

Are we talking about the same? Glibc is at version 2.33 at the moment: https://www.gnu.org/software/libc/ What does ldd --version show on your php8 docker image?

do-io commented 3 years ago

Debian Docker

ldd (Debian GLIBC 2.28-10) 2.28

Alpine Docker and now why I am seeing the problem

/var/www $ ldd --version
musl libc (x86_64)
Version 1.2.2
Dynamic Program Loader
Usage: /lib/ld-musl-x86_64.so.1 [options] [--] pathname

Looks like I need to find an apk for Alpine

do-io commented 3 years ago

BTW, I am in contact with libxl to check in on the builds and try to get a version of ldd and Glibc documented

Jan-E commented 3 years ago

OK. I am curious what changed in between 3.9.3.0 and 3.9.4.2, which effectively prohibited upgrading on CentOS/RHEL 6.

do-io commented 3 years ago

I was able to get 3.9.4.3 working with PHP:8-apache with php_excel now.

I have reached out to libxl to try and get access to the build and to try and get the supported build libraries supported or targetted

do-io commented 3 years ago

Here is my Dockerfile that looks to be working now...

FROM php:8-apache as build

ARG LIBXL_VERSION="3.9.4.3"
#ARG ZTS_VERSION="20190902"
ARG ZTS_VERSION="20200930"

RUN \
    apt-get update -y \
    && apt-get install -y wget git \

# Install libXL
    && cd /tmp \
    && wget http://www.libxl.com/download/libxl-lin-${LIBXL_VERSION}.tar.gz \
    && tar -zxv -f libxl-lin-${LIBXL_VERSION}.tar.gz \
    && cp /tmp/libxl-${LIBXL_VERSION}/lib64/libxl.so /usr/local/lib/libxl.so \
    && mkdir -p /usr/local/include/libxl_c/ \
    && cp /tmp/libxl-${LIBXL_VERSION}/include_c/* /usr/local/include/libxl_c/ \

# Install php_excel
    && cd /tmp \
    && docker-php-source extract \
    && git clone https://github.com/Jan-E/php_excel.git -b php7_with_pulls \
    && cd /tmp/php_excel \
    && phpize \
    && ./configure \
        --with-php-config=/usr/local/bin/php-config \
        --with-libxl-incdir=/usr/local/include/libxl_c/ \
        --with-libxml-dir=/usr/local/include/libxml2/ \
        --with-excel=../libxl-${LIBXL_VERSION}/ \
    && make \
    && cp /tmp/php_excel/modules/excel.so \
        /usr/local/lib/php/extensions/no-debug-non-zts-${ZTS_VERSION}/ \
    && cp /tmp/libxl-${LIBXL_VERSION}/lib64/libxl.so \
        /usr/lib/libxl.so \
    && apt-get remove -y wget git \
    && docker-php-source delete

FROM php:8-apache

ARG LIBXL_VERSION="3.9.4.3"
#ARG ZTS_VERSION="20190902"
ARG ZTS_VERSION="20200930"
ARG build=local
ARG sha=n/a
ARG config=production

RUN \
    apt-get update -y \
    && apt-get install -y libzip-dev libpng-dev \
    && docker-php-ext-install zip pdo_mysql gd calendar

COPY --from=build /usr/local/lib/php/extensions/no-debug-non-zts-${ZTS_VERSION}/excel.so /usr/local/lib/php/extensions/no-debug-non-zts-${ZTS_VERSION}/
COPY --from=build /usr/lib/libxl.so /usr/lib/
COPY ./config/excel.ini /usr/local/etc/php/conf.d/docker-php-ext-excel.ini
RUN docker-php-ext-enable excel

# Install PDFTK, wierd hack: pdftk requires
# opendjk-headless, openjdk-headless fails
# if /usr/share/man/man1 does not exist
RUN mkdir -p /usr/share/man/man1
RUN apt-get install -y pdftk

ENV VINOSHIPPER_ENVIRONMENT sandbox

COPY src/ /var/www/html/
COPY vendor/ /var/www/vendor/

#XDEBUG
RUN if [ "$config" = "xdebug" ]; \
    then pecl install xdebug; \
    else echo 'Skipping XDebug Installation'; \
    fi

RUN echo "{\"build\":\"${build}\", \"Sha\":\"${sha}\", \"ip\":\"<?= \$_SERVER['SERVER_ADDR'] ?>\"}" > /var/www/build.php
COPY "config/${config}.ini" "$PHP_INI_DIR/php.ini"
do-io commented 3 years ago

BTW, you should be able to create PRs now @Jan-E

do-io commented 3 years ago

I was finally able to install it successfully.