Menu

#1196 xlocale.h strikes again

v1.0 (example)
closed
None
5
2018-03-06
2018-02-14
No

With gsoap-2.8.62, glibc-2.26 and g++-7, I get:

$ g++ -c x.cpp
In file included from x.cpp:2:0:
/usr/include/stdsoap2.h:732:13: fatal error: xlocale.h: No such file or directory
 #   include <xlocale.h>
             ^~~~~~~~~~~
compilation terminated.
$ cat x.cpp 
#include <math.h>
#include <stdsoap2.h>

gsoap needs to cease unconditionally including <xlocale.h>.</xlocale.h>

Discussion

  • Robert van Engelen

    That is because other folks have complained that it would otherwise not compile on their Linux system!!

     
  • Robert van Engelen

    The problem is that we have several customers who cannot use gSOAP 2.8.5x and 2.8.6x on their Linux OS because of errors compiling locale_t, which is not defined without including xlocale.h explicitly. I have tested this on several Linux distros and it works fine. If you can share with me a #ifdef that tests for your specific OS version than we can consider using it,

     
  • Robert van Engelen

    xlocale.h is conditionally included, see stdsoap2.h:

    # elif defined(__GLIBC__) || defined(__GNU__)
    #  define HAVE_POLL
    #  define HAVE_SNPRINTF
    #  define HAVE_STRRCHR
    #  define HAVE_STRTOD
    #  define HAVE_SSCANF
    #  define HAVE_STRTOL
    #  define HAVE_STRTOUL
    #  define HAVE_STRTOLL
    #  define HAVE_STRTOULL
    #  define HAVE_GETTIMEOFDAY
    #  define HAVE_SYS_TIMEB_H
    #  define HAVE_FTIME
    #  define HAVE_RAND_R
    #  define HAVE_GMTIME_R
    #  define HAVE_ASCTIME_R
    #  define HAVE_LOCALTIME_R
    #  define HAVE_STRERROR_R
    #  define HAVE_TIMEGM
    #  define HAVE_WCTOMB
    #  define HAVE_MBTOWC
    #  define HAVE_ISNAN
    #  define HAVE_ISINF
    #  if !defined(__GNUC__) || __GNUC__ >= 4 /* gcc 3 and earlier often refuse to compile _l functions */
    #   define HAVE_STRTOD_L
    #   define HAVE_SSCANF_L
    #   define HAVE_LOCALE_H
    #   define HAVE_XLOCALE_H // PLACED BACK TO AVOID ERRORS WITH locale_t
    #  endif
    

    The config.h file that is build with ./configure also defines HAVE_XLOCALE_H. The config.h file is used to build libgsoap.a etc.

     
  • Jan Engelhardt

    Jan Engelhardt - 2018-02-15

    Your config.h may be used while building libgsoap.a, but not while building other party's software that tries to use (/usr/include/)stdsoap2.h, for several reasons:

    • third party software does not use any config.h of its own, in which case -DHAVE_CONFIG_H is not present in the compiler command-line (as in my example)
    • third party software may have their own config.h (and stdsoap2.h just went on to include that) which may not have a line for HAVE_XLOCALE_H at all because their configure.ac never tested for it

    .. fixing that will take me a while

     
  • Robert van Engelen

    I cannot remove #define HAVE_XLOCALE_H from the defined(__GLIBC__) || defined(__GNU__) because it breaks builds on some GNU Linux systems. If you have another #ifdef clause we can use to conditionally include xlocale.h then we should consider it.

     
  • Robert van Engelen

    Removing xlocale.h fails on x86_64-redhat-linux with g++ (GCC) 4.4.7 (Red Hat 4.4.7-4). As expected ./configure sets #define HAVE_XLOCALE_H 1 to build the libs, but compiling the source code without config.h fails.

     
  • Robert van Engelen

    • status: open --> closed
    • assigned_to: Robert van Engelen
     
  • Robert van Engelen

    I have made several improvements in 2.8.64 to deal with the xlocale.h issues. I removed #include <xlocale.h> again. If GNU Linux systems require xlocale.h then ./configure will of course find it but if not the new option ./configure --enable-xlocale will force this as well as the new -DWITH_INCLUDE_XLOCALE_H flag.

    The problem will likely still never go away as some Linux systems (Red Hat) require xlocale.h to be included to use locale_t and the locale _l functions.

    Hope this helps.

     
  • Jan Engelhardt

    Jan Engelhardt - 2018-03-04

    This is how headering ought to look like.

     
  • Jan Engelhardt

    Jan Engelhardt - 2018-03-06

    So what this patch does:

    • remove manual selection of xlocale.h. That's inside out - it should be completely automatic. If one's system has xlocale.h, it should be used, and if it is absent, it should not get used ever again. 2.8.63's approach with HAVE_XLOCALE_H was good as it was.
    • HAVE_* variables were put into config.h, but config.h was never installed to /usr/include, making the whole exercise pointless.
    • A file named config.h clashes with other software when installed to /usr/include. A new file, gsoap_config.h is put into existence.
    • Setting HAVE_* clashes with other software when used, so new names, GSOAP_WITH_* are used with gsoap_config.h.
     

Log in to post a comment.

MongoDB Logo MongoDB