Opened 16 years ago

Closed 14 years ago

Last modified 14 years ago

#1988 closed defect (fixed)

Detecting Xerces in configure may fail in some cases

Reported by: Ari Jolma Owned by: Mateusz Łoskot
Priority: normal Milestone:
Component: ConfigBuild Version: svn-trunk
Severity: normal Keywords: xerces
Cc: warmerdam, dron, Mateusz Łoskot

Description

Xerces seems to get included by default if Xerces is installed in a system. However, in configure.in with_xerces remains empty unless it is "yes". The result is that XERCES_INCLUDE becomes -I/include and not -I/usr/include as it should. Some of this is visible in my build.log (Fedora 7 with xerces-c and xerces-c-devel): http://map.hut.fi/files/Geoinformatica/snapshots/build.log

Attachments (1)

config.log (127.6 KB ) - added by whatnick 16 years ago.
MingW Config log

Download all attachments as: .zip

Change History (13)

comment:1 by warmerdam, 16 years ago

Cc: Mateusz Łoskot dron added
Component: defaultConfigBuild
Keywords: xerces added
Resolution: fixed
Status: newclosed
Version: unspecifiedsvn-trunk

Ari,

I think Andrey has corrected this problem with r12747 and r12744. Please reopen if the problem persists.

comment:2 by Mateusz Łoskot, 16 years ago

Resolution: fixed
Status: closedreopened

I'm reopening this ticket because recent changes seem to introduce new issues.

Now, when using all 3 options together, the --with-xerces=yes causes the remaining two options are skipped automatically without parsing and re-running Xerces files detection in custom location:

/configure --with-xerces=yes \
   --with-xerces-inc=/usr/local/xerces-2.8.0/include \
   --with-xerces-lib="-L/usr/local/xerces-2.8.0/lib -lxerces-c -lpthread"

I think the fix in r12747 is not good, because of two issues:

  • Setting with_xerces=no in line 1410 causes that condition in line 1415 is fails what prevents form testing passed include location and lib flags.
  • Not throwing detection failure if --with-xerces=yes is passed might be confusing, becasue user does not get any information about what's the reason Xerces has not been detected.

I'm going to attach patch re-fixing this problem.

comment:3 by warmerdam, 16 years ago

Cc: warmerdam added; Mateusz Łoskot removed
Milestone: 1.5.0
Owner: changed from warmerdam to Mateusz Łoskot
Status: reopenednew

Over to Mateusz to take care of.

comment:4 by Mateusz Łoskot, 16 years ago

Status: newassigned

comment:5 by Mateusz Łoskot, 16 years ago

Resolution: fixed
Status: assignedclosed

I've completely rewritten Xerces detection script and now it's available through external macro AX_LIB_XERCES located in gdal/m4/ax_xerces.m4.

The new version have been applied only to trunk (r12798)

How to request Xerces C++ Parser support with ./configure:

  1. Using no Xerces options:
    ./configure 
    

to implicitly ask it to detect Xerces under standard prefixes

  1. Using single option, variant 1:
    ./configure --with-xerces (or --with-xerces=yes)
    

to achieve the same effect as the command above

  1. Using single option, variant 2:
    ./configure --with-xerces=/usr/local/xerces-2.8.0
    

to detect Xerces under custom prefix /usr/local/xerces-2.8.0

  1. Using all three options together to a) request the Xerces support and b) tell the script where to look for headers and library files:
    ./configure --with-xerces=yes --with-xerces-inc=/incorrect/path --with-xerces-lib="-L/usr/local/xerces-2.8.0/lib -lxerces-c -lpthread"
    

In this 4th case, --with-xerces=yes is mandatory and its value must be yes, otherwise the two options --with-xerces-inc and --with-xerces-lib will be ignored automatically and Xerces detection will likely fail.

Summarizing, user must use single option --with-xerces (with values: yes, no or prefix path) or all three options together, no other combination is supported.

The main tests of Xerces detection script were run on Mac OS X 10.4 with Xerces installed under custom prefix: /usr/local/xerces-2.8.0

$ tree -d /usr/local/xerces-2.8.0
/usr/local/xerces-2.8.0
|-- include
|   `-- xercesc
|       |-- dom
|       |   |-- deprecated
|       |   `-- impl
|       |-- framework
|       |   `-- psvi
|       |-- internal
|       |-- parsers
|       |-- sax
|       |-- sax2
|       |-- util
|       |   |-- Compilers
|       |   |-- MsgLoaders
|       |   |   `-- InMemory
|       |   |-- NetAccessors
|       |   |   `-- Socket
|       |   |-- Platforms
|       |   |   `-- MacOS
|       |   |-- Transcoders
|       |   |   `-- MacOSUnicodeConverter
|       |   `-- regx
|       `-- validators
|           |-- DTD
|           |-- common
|           |-- datatype
|           `-- schema
|               `-- identity
`-- lib

I've run the same test againt Xerces 2.7.0 installed under prefix /usr/local/xerces-2.7.0 and Xerces 3.0.0 (SVN) installed in /usr/local/xerces-3.0.0.

Tests of different combinations of Xerces C++ Parser options provided by ./configure script:

  1. Xerces support requested implicitly (default behavior). Xerces availability is checked under standard prefixes /usr and /usr/local (in this example, there is no Xerces in there, but in custom location /usr/local/xerces-2.8.0, so detection fails but gracefully)
    ./configure
    
    checking for Xerces C++ Parser... no
    
  1. Xerces requested explicitly and expected to be found under standard prefixes (/usr or /usr/local)
    ./configure --with-xerces=yes (or --with-xerces)
    
    checking for Xerces C++ Parser... no
    configure: WARNING: Xerces C++ Parser support requested but headers or library not found. Specify valid prefix of Xerces C++ using --with-xerces=[DIR] or provide headers and linker flags using --with-xerces-inc and --with-xerces-lib
    
  1. Explicitly request to disable Xerces support
    ./configure --with-xerces=no (or --without-xerces)
    
    checking for Xerces C++ Parser... no
    
  1. Xerces requested explicitly by specifying valid custom installation prefix
    ./configure --with-xerces=/usr/local/xerces-2.8.0
    
    checking for Xerces C++ Parser headers in /usr/local/xerces-2.8.0/include and /usr/local/xerces-2.8.0/include/xercesc... found
    checking for Xerces C++ Parser libraries... found
    checking for Xerces C++ Parser... yes
    checking if Xerces C++ Parser version is >= 2.7.0... yes
    
  1. Xerces requested explicitly using (incorrect) installation prefix (--with-xerces option) together with include and lib options. Detection fails because value of --with-xerces option is not set to yes, so next two options are ignored automatically. If value of --with-xerces is not yes then it's considered to be an installation prefix (but the path is incorrect in this example, no Xerces lives there)
    ./configure --with-xerces=/usr/local --with-xerces-inc=/usr/local/xerces-2.8.0/include --with-xerces-lib="-L/usr/local/xerces-2.8.0/lib -lxerces-c -lpthread"
    
    checking for Xerces C++ Parser headers in /usr/local/include and /usr/local/include/xercesc... not found
    checking for Xerces C++ Parser... no
    
  1. Similar example to the one above, Xerces requested explicitly but --with-xerces=yes is missing, so latter two options are ignored
    ./configure --with-xerces-inc=/usr/local/xerces-2.8.0/include --with-xerces-lib="-L/usr/local/xerces-2.8.0/lib -lxerces-c -lpthread"
    
    checking for Xerces C++ Parser... no
    
  1. Xerces requested explicitly but --with-xerces-lib option with linker flags is missing
    ./configure --with-xerces=yes --with-xerces-inc=/usr/local/xerces-2.8.0/include
    
    checking for Xerces C++ Parser... no
    configure: WARNING: Xerces C++ Parser support requested but headers or library not found. Specify valid prefix of Xerces C++ using --with-xerces=[DIR] or provide headers and linker flags using --with-xerces-inc and --with-xerces-lib
    
  1. Xerces requested explicitly but using invalid include path, then linker flags are ignored even if correct
    ./configure --with-xerces=yes --with-xerces-inc=/incorrect/path --with-xerces-lib="-L/usr/local/xerces-2.8.0/lib -lxerces-c -lpthread"
    
    checking for Xerces C++ Parser headers in /incorrect/path and /incorrect/path/xercesc... not found
    checking for Xerces C++ Parser... no
    
  1. Xerces requested explicitly using valid include path but invalid linker flags
    ./configure --with-xerces=yes --with-xerces-inc=/usr/local/xerces-2.8.0/include --with-xerces-lib="incorrect flags"
    
    checking for Xerces C++ Parser headers in /usr/local/xerces-2.8.0/include and /usr/local/xerces-2.8.0/include/xercesc... found
    checking for Xerces C++ Parser libraries... not found
    checking for Xerces C++ Parser... no
    
  1. Xerces requested explicitly using valid include path but valid linker flags
    ./configure --with-xerces=yes --with-xerces-inc=/usr/local/xerces-2.8.0/include --with-xerces-lib="-L/usr/local/xerces-2.8.0/lib -lxerces-c -lpthread"
    
    checking for Xerces C++ Parser headers in /usr/local/xerces-2.8.0/include and /usr/local/xerces-2.8.0/include/xercesc... found
    checking for Xerces C++ Parser libraries... found
    checking for Xerces C++ Parser... yes
    checking if Xerces C++ Parser version is >= 2.7.0... yes
    
  1. Xerces disabled explicitly by using --with-xerces=no, include and lib flags are ignored automatically
    ./configure --with-xerces=no --with-xerces-inc=/usr/local/xerces-2.8.0/include --with-xerces-lib="-L/usr/local/xerces-2.8.0/lib -lxerces-c -lpthread"
    
    checking for Xerces C++ Parser... no
    

A note about Xerces version requirement. It's possible to set (or not) minimal version requirement when calling AX_LIB_XERCES macro inside the configure.in. Currently, this requirement is set to Xerces 2.7.0 and if you try to use older version, for example 2.5.0, you might encounter warning like this:

checking for Xerces C++ Parser headers in /usr/local/xerces-2.5.0/include and /usr/local/xerces-2.5.0/include/xercesc... found
checking for Xerces C++ Parser libraries... found
checking for Xerces C++ Parser... yes
checking if Xerces C++ Parser version is >= 2.7.0... no
configure: WARNING: Found Xerces C++ Parser 2.5.0, which is older than required. Possible compilation failure.

I'm closing this ticket.

comment:6 by whatnick, 16 years ago

Resolution: fixed
Status: closedreopened

The Xerces detection is failing for MingW with the following configure line: CPPFLAGS=-DXML_LIBRARY ./configure --with-python --with-local --with-grass=/local/grass-6.3.0cvs --with-expat=yes --with-xerces=yes --with-pg=/local/pgsql/bin/pg_config.exe It was working in the older simpler version, that CPPFLAG in the beginning needs to be set for Xerces to work in MingW. Also Expat detection is failing and used to work.

by whatnick, 16 years ago

Attachment: config.log added

MingW Config log

comment:7 by whatnick, 16 years ago

Revision 12797 detects Xerces(and Expat) on MingW and works. could you include a failsafe simple test which is a baseline check and could be enabled somehow ?

comment:8 by Mateusz Łoskot, 16 years ago

Resolution: fixed
Status: reopenedclosed

We've discussed it in details on #qgis channel with whatnick. We tried to build very simple program using Xerces (as well as Expat) without any dependency on GDAL. MinGW failed on linking against Xerces (Expat). Because MinGW is not supported, I'm not inclined to test it myself but wait for someone who is able to find out why MinGW is failing and provide patches if necessary.

I'm closing this ticket as fixed.

comment:9 by Ari Jolma, 14 years ago

Cc: Mateusz Łoskot added
Milestone: 1.5.0
Summary: If Xerces is on by default, the Xerces include dir is not correctDetecting Xerces in configure may fail in some cases

I'm not reopening this, but make a note that this problem still exists at least in MinGW. There is something I don't quite understand and suspect it's a (non MinGW related) bug in ax_lib_xerces.m4.

I have the case 10 above. Basically I want to say

--with-xerces=yes \
--with-xerces-inc=/usr/local/include \
--with-xerces-lib="-L/usr/local/bin -lxerces-c-3-0"

this leads to the first case in "collect include/lib paths and flags". I suspect it *should* lead to the 2nd. It leads to the first also if I specify --with-xerces=/usr/local. Because it leads to the first, the xerces_include_dir and xerces_lib_flags get written over by hard coded values *instead* what I just specified in the command line.

The simple remedy is to edit configure and comment out some lines:

#xerces_include_dir="$xerces_prefix/include"
xerces_include_dir2="$xerces_prefix/include/xercesc"
#if test "$xerces_prefix" = "/usr"; then
#    xerces_lib_flags="-lxerces-c -lpthread"
#else
#    xerces_lib_flags="-L$xerces_prefix/lib -lxerces-c -lpthread"
#fi
run_xerces_test="yes"

I don't have time now for more, but I suspect setting xerces_prefix when withwal = yes is confusing the test.

I changed the summary. Cc to mloskot added as he's the author of ax_lib_xerces.m4.

comment:10 by Mateusz Łoskot, 14 years ago

Resolution: fixed
Status: closedreopened

comment:11 by Mateusz Łoskot, 14 years ago

Resolution: fixed
Status: reopenedclosed

Ari, thanks for the update. It is helpful. Please, try of the fix r19772 in trunk makes it working for you

comment:12 by Ari Jolma, 14 years ago

It works for me. Thanks.

Note: See TracTickets for help on using tickets.