Hi,
I aim to build nginx from source, statically linked, and run into issues
when `http_xslt_module` is enabled or I'm building with NJS 0.7.10
(which also needs xslt).
I've created a simplified docker build to debug this issue at
https://git.compilenix.org/CompileNix/docker-nginx-static
The error occures while running `./auto/configure` if
`--with-ld-opt="-static"` is added. The build succeeds without it
(remove line 176 from Dockerfile).
The configure ends with:
checking for libxslt ... not found
checking for libxslt in /usr/local/ ... not found
checking for libxslt in /usr/pkg/ ... not found
checking for libxslt in /opt/local/ ... not found
./auto/configure: error: the HTTP XSLT module requires the libxml2/libxslt
libraries. You can either do not enable the module or install the libraries.
The issue is not that libxml2 and libxslt aren't installed, they are.
I've looked into why libxslt is reported to be "not found" by inspecting
the configure log file `objs/autoconf.err`, which shows the following error:
``
checking for libxslt
/usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../x86_64-alpine-linux-musl/bin/ld:
/usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../lib/libxml2.a(libxml2_la-xmlIO.o):
in function `xmlFreeZMemBuff':
/home/buildozer/aports/main/libxml2/src/libxml2-2.10.3/xmlIO.c:1482:
undefined reference to `deflateEnd'
/usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../x86_64-alpine-linux-musl/bin/ld:
/usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../lib/libxml2.a(libxml2_la-xmlIO.o):
in function `xmlGzfileOpenW':
/home/buildozer/aports/main/libxml2/src/libxml2-2.10.3/xmlIO.c:1172:
undefined reference to `gzdopen'
<for more see full build log linked below>
Here is the full build log:
https://compilenix.org/static/95Yeyaxv/build-static.log
If you are wondering why I also build libxslt from source instead of
using the alpine libxslt-dev package.. libxslt-dev does not contain
"libxslt.a", which is required for static linking.
Additionally: I've also looked into other distros like ubuntu, fedora or
gentoo. None of them install "libxslt.a" and show the same configure
error messages.
Steps to reproduce:
git clone https://git.compilenix.org/CompileNix/docker-nginx-static.git
cd docker-nginx-static
./build.sh -t docker-nginx-static --no-cache | tee build.log
Any help, suggestions or hints are very welcome :)
Hello!
On Sun, Feb 12, 2023 at 05:31:30PM +0100, Kevin Weis via nginx wrote:
> Hi,
> I aim to build nginx from source, statically linked, and run into issues
> when `http_xslt_module` is enabled or I'm building with NJS 0.7.10
> (which also needs xslt).
>
> I've created a simplified docker build to debug this issue at
> https://git.compilenix.org/CompileNix/docker-nginx-static
>
> The error occures while running `./auto/configure` if
> `--with-ld-opt="-static"` is added. The build succeeds without it
> (remove line 176 from Dockerfile).
>
> The configure ends with:
> ```
> checking for libxslt ... not found
> checking for libxslt in /usr/local/ ... not found
> checking for libxslt in /usr/pkg/ ... not found
> checking for libxslt in /opt/local/ ... not found
>
> ./auto/configure: error: the HTTP XSLT module requires the libxml2/libxslt
> libraries. You can either do not enable the module or install the libraries.
> ```
>
> The issue is not that libxml2 and libxslt aren't installed, they are.
>
> I've looked into why libxslt is reported to be "not found" by inspecting
> the configure log file `objs/autoconf.err`, which shows the following error:
> ``
> checking for libxslt
>
> /usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../x86_64-alpine-linux-musl/bin/ld:
> /usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../lib/libxml2.a(libxml2_la-xmlIO.o):
> in function `xmlFreeZMemBuff':
> /home/buildozer/aports/main/libxml2/src/libxml2-2.10.3/xmlIO.c:1482:
> undefined reference to `deflateEnd'
> /usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../x86_64-alpine-linux-musl/bin/ld:
> /usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../lib/libxml2.a(libxml2_la-xmlIO.o):
> in function `xmlGzfileOpenW':
> /home/buildozer/aports/main/libxml2/src/libxml2-2.10.3/xmlIO.c:1172:
> undefined reference to `gzdopen'
>
> <for more see full build log linked below>
> ```
>
> Here is the full build log:
> https://compilenix.org/static/95Yeyaxv/build-static.log
>
> If you are wondering why I also build libxslt from source instead of
> using the alpine `libxslt-dev` package.. `libxslt-dev` does not contain
> "libxslt.a", which is required for static linking.
>
> Additionally: I've also looked into other distros like ubuntu, fedora or
> gentoo. None of them install "libxslt.a" and show the same configure
> error messages.
>
> Steps to reproduce:
> ```
> git clone https://git.compilenix.org/CompileNix/docker-nginx-static.git
> cd docker-nginx-static
> ./build.sh -t docker-nginx-static --no-cache | tee build.log
> ```
>
> Any help, suggestions or hints are very welcome :)
Static linking requires more than just "-static". In particular,
for all the libraries being used you'll have to manually provide
library dependencies.
The particular error suggests that libxml2 depends on zlib, so
something like "--with-ld-opt="-static -lz"" should help.
Likely there will be other similar errors and you'll have to
include other libraries as well. For example, on FreeBSD static
linking with libxslt requires "-static -lz -lm -llzma -lmd".
Something like
pkg-config --static libxslt
might be a good starting point for full list of required
libraries, assuming libxslt package information is properly
installed. Alternatively, ldd on the dynamic library might be a
good start.
Note well that in general it might not be a good idea to compile
things statically unless you have some good reasons to and
understand possible consequences.
--
Maxim Dounin
http://mdounin.ru/
checking for libxslt ... not found checking for libxslt in /usr/local/ ... not found checking for libxslt in /usr/pkg/ ... not found checking for libxslt in /opt/local/ ... not found
./auto/configure: error: the HTTP XSLT module requires the libxml2/libxslt libraries. You can either do not enable the module or install the libraries.
Here is the full build log: https://compilenix.org/static/95Yeyaxv/build-static.log
If you are wondering why I also build libxslt from source instead of using the alpine
libxslt-dev
package..libxslt-dev
does not contain "libxslt.a", which is required for static linking.Additionally: I've also looked into other distros like ubuntu, fedora or gentoo. None of them install "libxslt.a" and show the same configure error messages.
Steps to reproduce:
Any help, suggestions or hints are very welcome :)
-- Best regards Kevin Weis Pronouns: he / him
https://compilenix.org -------------- next part -------------- A non-text attachment was scrubbed... Name: OpenPGP_0x3B3F8B753D8DDB10.asc Type: application/pgp-keys Size: 1371 bytes Desc: OpenPGP public key URL: http://mailman.nginx.org/pipermail/nginx/attachments/20230212/5ae20607/attachment.bin -------------- next part -------------- A non-text attachment was scrubbed... Name: OpenPGP_signature Type: application/pgp-signature Size: 236 bytes Desc: OpenPGP digital signature URL: http://mailman.nginx.org/pipermail/nginx/attachments/20230212/5ae20607/attachment-0001.bin ```