Hi, I have an issue on installing xmlreader under docker container, with image php:7.1.1-fpm
$ apt-get update && apt-get install -y libxml2-dev
$ docker-php-ext-install xmlreader
...
creating libtool
appending configuration tag "CXX" to libtool
configure: creating ./config.status
config.status: creating config.h
/bin/bash /usr/src/php/ext/xmlreader/libtool --mode=compile cc -I. -I/usr/src/php/ext/xmlreader -DPHP_ATOM_INC -I/usr/src/php/ext/xmlreader/include -I/usr/src/php/ext/xmlreader/main -I/usr/src/php/ext/xmlreader -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -I/usr/include/libxml2 -fstack-protector-strong -fpic -fpie -O2 -DHAVE_CONFIG_H -fstack-protector-strong -fpic -fpie -O2 -c /usr/src/php/ext/xmlreader/php_xmlreader.c -o php_xmlreader.lo
mkdir .libs
cc -I. -I/usr/src/php/ext/xmlreader -DPHP_ATOM_INC -I/usr/src/php/ext/xmlreader/include -I/usr/src/php/ext/xmlreader/main -I/usr/src/php/ext/xmlreader -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -I/usr/include/libxml2 -fstack-protector-strong -fpic -fpie -O2 -DHAVE_CONFIG_H -fstack-protector-strong -fpic -fpie -O2 -c /usr/src/php/ext/xmlreader/php_xmlreader.c -fPIC -DPIC -o .libs/php_xmlreader.o
/usr/src/php/ext/xmlreader/php_xmlreader.c:32:28: fatal error: ext/dom/dom_ce.h: No such file or directory
#include "ext/dom/dom_ce.h"
^
compilation terminated.
Seems cc compiler cannot find ext/dom/dom_ce.h, Is there any ways to link/include the directory?
So, it works in the PHP 5 images, but not 7.0 or 7.1. The following seems to work around the problem:
root@1a38316952d9:/# apt-get update && apt-get install -y libxml2-dev
root@1a38316952d9:/# export CFLAGS="-I/usr/src/php"
root@1a38316952d9:/# docker-php-ext-install xmlreader
# Dockerfile:
# do an ENV line or inline the flags on the RUN
# I would lean toward the inline, since CFLAGS could affect any other C based build
# ENV CLFAGS -I/usr/src/php
RUN apt-get update \
&& apt-get install -y libxml2-dev \
&& CFLAGS="-I/usr/src/php" docker-php-ext-install xmlreader \
# should be able to uninstall the dev now
&& apt-get purge -y --auto-remove libxml2-dev \
&& rm -r /var/lib/apt/lists/*
Thanks your help @yosifkit
Thanks. you're great @yosifkit
So, it works in the PHP 5 images, but not
7.0or7.1. The following seems to work around the problem:root@1a38316952d9:/# apt-get update && apt-get install -y libxml2-dev root@1a38316952d9:/# export CFLAGS="-I/usr/src/php" root@1a38316952d9:/# docker-php-ext-install xmlreader# Dockerfile: # do an ENV line or inline the flags on the RUN # I would lean toward the inline, since CFLAGS could affect any other C based build # ENV CLFAGS -I/usr/src/php RUN apt-get update \ && apt-get install -y libxml2-dev \ && CFLAGS="-I/usr/src/php" docker-php-ext-install xmlreader \ # should be able to uninstall the dev now && apt-get purge -y --auto-remove libxml2-dev \ && rm -r /var/lib/apt/lists/*
Using php:7.2-apache image, I solved using:
RUN apt-get update \
&& apt-get install -y libxml2-dev \
&& export EXTRA_CFLAGS="-I/usr/src/php" \
&& docker-php-ext-install xmlreader
Most helpful comment
So, it works in the PHP 5 images, but not
7.0or7.1. The following seems to work around the problem: