c++configure

./configure --with-libxml2=/usr/lib64/ still get issue `No XML parser found` when configure the apr


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

Solution

  • 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.