0

In my centos7 container, I configure the downloaded /root/apr by cloning the latest version:

git clone https://github.com/apache/apr.git 

when I execute the ./configure

I get error:

checking for libxml/parser.h... no
checking Expat 1.95.x... no
checking old Debian-packaged expat... no
checking old FreeBSD-packaged expat... no
checking Expat 1.0/1.1... no
  setting LDFLAGS to "-L/usr/local/lib"
  setting INCLUDES to "-I/usr/local/include"
checking Expat 1.95.x in /usr/local... no
  setting APRUTIL_EXPORT_LIBS to ""
  setting APRUTIL_LIBS to ""
configure: error: No XML parser found!  Please specify --with-expat or --with-libxml2

then I installed libxml2:

yum install -y libxml2

the libxml2 libraries are:

sh-4.2# ls /usr/lib64/ | grep libxml
libxml2.so.2
libxml2.so.2.9.1

but I still get this error when I execute this configure command:

./configure  --with-libxml2=/usr/lib64/

Before asking this question I have tried: https://stackoverflow.com/a/9783138/7640404


EDIT-01

After installed libxml2-devel:

yum install libxml2-devel

there have libxml2.so

sh-4.2# ls /usr/lib64 | grep libxml
libxml2.so
libxml2.so.2
libxml2.so.2.9.1

the include:

sh-4.2# ls /usr/include/libxml2/libxml/
DOCBparser.h  catalog.h   globals.h   parserInternals.h   tree.h      xmlautomata.h  xmlregexp.h        xmlversion.h
HTMLparser.h  chvalid.h   hash.h      pattern.h           uri.h       xmlerror.h     xmlsave.h          xmlwriter.h
HTMLtree.h    debugXML.h  list.h      relaxng.h           valid.h     xmlexports.h   xmlschemas.h       xpath.h
SAX.h         dict.h      nanoftp.h   schemasInternals.h  xinclude.h  xmlmemory.h    xmlschemastypes.h  xpathInternals.h
SAX2.h        encoding.h  nanohttp.h  schematron.h        xlink.h     xmlmodule.h    xmlstring.h        xpointer.h
c14n.h        entities.h  parser.h    threads.h           xmlIO.h     xmlreader.h    xmlunicode.h

but still get this issue:

./configure --prefix=/usr/local/apr --with-libxml2=/usr/lib64/
checking sql.h presence... no
checking for sql.h... no
checking odbc/sql.h usability... no
checking odbc/sql.h presence... no
checking for odbc/sql.h... no
checking for xml2-config... no
  adding "-I/usr/lib64//include/libxml2" to CPPFLAGS
  adding "-lxml2" to LIBS
configure: checking for libxml2 in /usr/lib64/
checking libxml/parser.h usability... no
checking libxml/parser.h presence... no
checking for libxml/parser.h... no
checking Expat 1.95.x... no
checking old Debian-packaged expat... no
checking old FreeBSD-packaged expat... no
checking Expat 1.0/1.1... no
  setting LDFLAGS to "-L/usr/local/lib"
  setting INCLUDES to "-I/usr/local/include"
checking Expat 1.95.x in /usr/local... no
  setting APRUTIL_EXPORT_LIBS to ""
  setting APRUTIL_LIBS to ""
configure: error: No XML parser found!  Please specify --with-expat or --with-libxml2

EDIT-02

thanks for William Pursell. I tried

CFLAGS="-I/usr/include/libxml2/libxml/"  ./configure 

but still not work.

and even changed the configure file to add -I/usr/include/libxml2/libxml:


  if test "x$INCLUDES" = "x"; then
    test "x$silent" != "xyes" && echo "  setting INCLUDES to \"-I/usr/local/include  -I/usr/local/include -I/usr/include/libxml2/libxml \""
    INCLUDES="-I/usr/local/include -I/usr/include/libxml2/libxml"

still get this error:

...
checking old FreeBSD-packaged expat... no
checking Expat 1.0/1.1... no
  setting LDFLAGS to "-L/usr/local/lib"
  setting INCLUDES to "-I/usr/local/include  -I/usr/local/include -I/usr/include/libxml2/libxml "
checking Expat 1.95.x in /usr/local... no
  setting APRUTIL_EXPORT_LIBS to ""
  setting APRUTIL_LIBS to ""
configure: error: No XML parser found!  Please specify --with-expat or --with-libxml2

EDIT-03

I tried :

./configure --with-libxml2=/usr/lib64/include/libxml2

but still get error:

checking langinfo.h usability... yes
checking langinfo.h presence... yes
checking for langinfo.h... yes
checking for nl_langinfo... yes
  setting have_unicode_fs to "0"
  setting apr_has_xthread_files to "0"
  setting apr_procattr_user_set_requires_password to "0"
  setting apr_thread_func to ""
  setting apr_has_user to "1"
Applying apr-util hints file rules for aarch64-unknown-linux-gnu
checking for default DBM... sdbm (default)
checking for pg_config... no
checking libpq-fe.h usability... no
checking libpq-fe.h presence... no
checking for libpq-fe.h... no
checking postgresql/libpq-fe.h usability... no
checking postgresql/libpq-fe.h presence... no
checking for postgresql/libpq-fe.h... no
checking sqlite3.h usability... no
checking sqlite3.h presence... no
checking for sqlite3.h... no
checking sqlite.h usability... no
checking sqlite.h presence... no
checking for sqlite.h... no
checking for odbc_config... no
checking sql.h usability... no
checking sql.h presence... no
checking for sql.h... no
checking odbc/sql.h usability... no
checking odbc/sql.h presence... no
checking for odbc/sql.h... no
checking for xml2-config... no
  adding "-I/usr/lib64/include/libxml2/include/libxml2" to CPPFLAGS
  adding "-lxml2" to LIBS
configure: checking for libxml2 in /usr/lib64/include/libxml2
checking libxml/parser.h usability... no
checking libxml/parser.h presence... no
checking for libxml/parser.h... no
checking Expat 1.95.x... no
checking old Debian-packaged expat... no
checking old FreeBSD-packaged expat... no
checking Expat 1.0/1.1... no
  setting LDFLAGS to "-L/usr/local/lib"
  setting INCLUDES to "-I/usr/local/include  -I/usr/local/include -I/usr/include/libxml2/libxml "
checking Expat 1.95.x in /usr/local... no
  setting APRUTIL_EXPORT_LIBS to ""
  setting APRUTIL_LIBS to ""
configure: error: No XML parser found!  Please specify --with-expat or --with-libxml2

EDIT-04

When I execute ./configure --with-libxml2=/usr/include/libxml2

I still get error:

checking for libpq-fe.h... no
checking postgresql/libpq-fe.h usability... no
checking postgresql/libpq-fe.h presence... no
checking for postgresql/libpq-fe.h... no
checking sqlite3.h usability... no
checking sqlite3.h presence... no
checking for sqlite3.h... no
checking sqlite.h usability... no
checking sqlite.h presence... no
checking for sqlite.h... no
checking for odbc_config... no
checking sql.h usability... no
checking sql.h presence... no
checking for sql.h... no
checking odbc/sql.h usability... no
checking odbc/sql.h presence... no
checking for odbc/sql.h... no
checking for xml2-config... no
  adding "-I/usr/include/libxml2/include/libxml2" to CPPFLAGS
  adding "-lxml2" to LIBS
configure: checking for libxml2 in /usr/include/libxml2
checking libxml/parser.h usability... no
checking libxml/parser.h presence... no
checking for libxml/parser.h... no
checking Expat 1.95.x... no
checking old Debian-packaged expat... no
checking old FreeBSD-packaged expat... no
checking Expat 1.0/1.1... no
  setting LDFLAGS to "-L/usr/local/lib"
  setting INCLUDES to "-I/usr/local/include  -I/usr/local/include -I/usr/include/libxml2/libxml "
checking Expat 1.95.x in /usr/local... no
  setting APRUTIL_EXPORT_LIBS to ""
  setting APRUTIL_LIBS to ""
configure: error: No XML parser found!  Please specify --with-expat or --with-libxml2
TallChuck
  • 1,725
  • 11
  • 28
qg_java_17137
  • 3,310
  • 10
  • 41
  • 84
  • 1
    There does not appear to be a `libxml2.so` installed. You probably need to install `libxml2-devel` – William Pursell Jan 09 '23 at 12:47
  • 1
    In general, the `libfoo` package contains things you need to execute (libfoo.so.n and libfoo.so.n.m.p) while `libfoo-devel` contains the things you need to build (eg foo.h and libfoo.so) – William Pursell Jan 09 '23 at 12:50
  • It still do not work. – qg_java_17137 Jan 10 '23 at 01:50
  • 1
    Don't rely on the `--with-*` flags. They are mostly useless, and won't do what you want. Instead, just set LDFLAGS and CPPFLAGS appropriately. In your case, it seems that the configure script is trying to find the header file in /usr/lib64/include/libxml2, but it is in /usr/include/libxml2/libxml/. The --with flags are just convenience wrappers that set LDFLAGS and CPPFLAGS and trick the user into thinking that they can specify which library to use (if you have libfoo in two places, and libbar in two places, you cannot pick them with fine granularity as the --with flags imply) – William Pursell Jan 10 '23 at 16:09
  • As log shows it successfully appends libxml path to CFLAGS, but fails to find `libxml/parser.h` and it looks like it attemts to find linxml folder directly in `/usr/lib64` - folder you specified. Try put `--with-libxml2=/usr/include/libxml2` instead. – Sugar Jan 12 '23 at 11:04
  • @Sugar it still not work. – qg_java_17137 Jan 17 '23 at 16:23
  • Which directory are you executing `./configure` from? – l'L'l Jan 18 '23 at 03:40
  • @l'L'l `/root/apr` – qg_java_17137 Jan 18 '23 at 04:02
  • Try doing `CFLAGS="-I/usr/include/libxml2/"` without `libxml` appended to it. – l'L'l Jan 18 '23 at 05:05

1 Answers1

1

In a plain Centos 7 container

docker run --rm -it centos:centos7

With these dependencies installed

yum groupinstall "Development Tools"
yum install git which libxml2-devel
git clone https://github.com/apache/apr.git # 5a86456
cd apr

This successfully configures and builds the project:

./buildconf
./configure CFLAGS=-I/usr/include/libxml2
make

It will report something like this

checking libxml/parser.h usability... yes
checking libxml/parser.h presence... no
configure: WARNING: libxml/parser.h: accepted by the compiler, rejected by the preprocessor!
configure: WARNING: libxml/parser.h: proceeding with the compiler's result
checking for libxml/parser.h... yes
checking for xmlCreatePushParserCtxt in -lxml2... yes
  setting APRUTIL_CPPFLAGS to ""
  setting APRUTIL_PRIV_INCLUDES to ""
  setting APRUTIL_LIBS to "-lxml2"

The --with-libxml2 flag seems unnecessary.

Etienne Laurin
  • 6,731
  • 2
  • 27
  • 31