View Ticket
Not logged in
Ticket Hash: 2b1697e601ed2db015a59cd3be2de2d7bc3c2266
Title: libspatialite.so: undefined reference to `xmlNanoHTTPCleanup'
Status: Closed Type: Build_Problem
Severity: Critical Priority: Immediate
Subsystem: Resolution: Not_A_Bug
Last Modified: 2024-07-10 11:52:33
Version Found In: 5.1.0
User Comments:
anonymous added on 2024-01-04 04:07:25:

I'm trying to get libspatialite installed (for use with GeoDjango) on Amazon Linux 2 (AWS Lambda Python)

The base image here (https://github.com/lambgeo/docker-lambda) helped a lot as I wasn't able to get GDAL working myself.

So I have that and now I'm trying to compile libspatialite on top. I have:

FROM ghcr.io/lambgeo/lambda-gdal:3.8 as gdal

RUN yum update -y && \
    yum install -y git autoconf libtool flex bison cmake make \
      tar gzip gcc gcc-c++ automake16 libpng-devel nasm \
      libxml2-devel readline-devel openssl-devel curl-devel \
      cmake3 && \
    yum clean all && \
    rm -rf /var/cache/yum /var/lib/yum/history

ENV PREFIX /opt

WORKDIR /opt

ENV LD_LIBRARY_PATH $PREFIX/lib:$LD_LIBRARY_PATH

# pkg-config
ENV PKGCONFIG_VERSION=0.29.2
RUN mkdir /tmp/pkg-config \
  && curl -sfL https://pkg-config.freedesktop.org/releases/pkg-config-${PKGCONFIG_VERSION}.tar.gz | tar zxf - -C /tmp/pkg-config --strip-components=1 \
  && cd /tmp/pkg-config \
  && CFLAGS="-O2 -Wl,-S" ./configure --prefix=$PREFIX --with-internal-glib \
  && make -j $(nproc) --silent && make install && make clean \
  && rm -rf /tmp/pkg-config

ENV PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig/

# https://docs.djangoproject.com/en/5.0/ref/contrib/gis/install/spatialite/

# spatialite
RUN mkdir /tmp/spatialite \
  && curl -sfL https://www.gaia-gis.it/gaia-sins/libspatialite-sources/libspatialite-5.1.0.tar.gz | tar zxf - -C /tmp/spatialite --strip-components=1 \
  && cd /tmp/spatialite \
  && CFLAGS="-I/opt/include" LDFLAGS="-L/opt/lib" \
    ./configure --enable-freexl=no --enable-minizip=no --disable-rttopo \
  && make -j $(nproc) --silent && make install && make clean \
  && rm -rf /tmp/spatialite

I've already added a few flags (--enable-freexl=no --enable-minizip=no --disable-rttopo) in the libspatialite part to get around things that failed to build.

Now I have reached this:

 > [gdal 5/5] RUN mkdir /tmp/spatialite   && curl -sfL https://www.gaia-gis.it/gaia-sins/libspatialite-sources/libspatialite-5.1.0.tar.gz | tar zxf - -C /tmp/spatialite --strip-components=1   && cd /tmp/spatialite   && CFLAGS="-I/opt/include" LDFLAGS="-L/opt/lib" ./configure --enable-freexl=no --enable-minizip=no --disable-rttopo   && make -j $(nproc) --silent && make install && make clean   && rm -rf /tmp/spatialite:
213.0 make[2]: *** [demo1] Error 1
213.0 make[2]: *** [demo5] Error 1
213.1 /tmp/spatialite/src/.libs/libspatialite.so: undefined reference to `xmlNanoHTTPCleanup'
213.1 collect2: error: ld returned 1 exit status

I believe it's something related to libxml2

I have yum install libxml2-devel at the top of the Dockerfile.

I have confirmed that /opt/include/libxml2 and /opt/lib/libxml2.so both exist

I wondered if libxml2 had been built with --with-http=off so I used yumdownloader and rpm2cpio to check the rpm that was installed (libxml2-2.9.1-6.amzn2.5.13.src.rpm) but it apparently defines only default configure options:

%build
%configure
make %{_smp_mflags}

I can see the file /opt/include/libxml2/libxml/nanohttp.h exists and inside it there is:

XMLPUBFUN void XMLCALL
	xmlNanoHTTPCleanup	(void);

I tried adding CFLAGS="-I/opt/include -I/opt/include/libxml2/libxml" to the configure line but I get the same error when building.

Not really sure what else to try.


anonymous added on 2024-06-23 20:13:24:

I had the same problem with libxml2 version 2.13.0. When I fell back to version 2.12.7 the problem the symbols resolved.


sandro added on 2024-07-10 11:52:33:

This morning while I was trying to update the Windows version I encountered this problem for the first time.

after some investigations I discovered that the cause is in the more recent versions of libxml2

in all previous versions (up to 2.12.7) HTTP support was always enabled, but starting from the new 2.13.x it is disabled by default.

to enable HTTP support again, you need to build libxml2 by passing the -DLIBXML2_WITH_HTTP=ON option to CMake

at this point everything is back to normal, but a message is issued warning that xmlNanoHTTPCleanup is now deprecated