libxml doesn’t compile

The latest CVS version of libxml2 doesn’t build. Linking fails with messages:

../../.libs/libxml2.so: undefined reference to `pthread_getspecific'
../../.libs/libxml2.so: undefined reference to `pthread_once'
../../.libs/libxml2.so: undefined reference to `pthread_key_create'
../../.libs/libxml2.so: undefined reference to `pthread_setspecific'

It seems I’m not alone. Here is a message form the libxml2 mailing list: “Linker error Compiling off the HEAD“.

The sad thing is that it will not be fixed for some time: Re: Linker error Compiling off the HEAD:

… and I don’t have a complete solution. Probably need a compiler portability expert input to get it right…

My workaround is bad. In several Makefiles (Makefile, doc/examples/Makefile, example/Makefile), I changes the line

LDADDS =  $(top_builddir)/libxml2.la  -lz $(ICONV_LIBS) -lm 

to

LDADDS =  $(top_builddir)/libxml2.la  -lz $(ICONV_LIBS) -lm -lpthread 

Similar actions are required for libxslt (in xsltproc/Makefile).

4 Responses to “libxml doesn’t compile”

  1. libxml2 user Says:

    You can also build with the –without-threads option:

    ./configure –without-threads

    This turns off threads, but will allow the build to complete without error.

  2. olpa Says:

    Yes, it’s also a workaround.

  3. LazyTiger Says:

    may be better to patch ./threads.c ? that works for me (gcc 3.2.3 RHEL3).
    build whith threads and check got passed.

    — threads.c.old 2005-05-04 13:58:44.000000000 +0400
    +++ threads.c 2005-07-18 23:21:38.000000000 +0400
    @@ -51,7 +51,7 @@
    static int libxml_is_threaded = -1;
    #ifdef __GNUC__
    #ifdef linux
    -#if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || (__GNUC__ > 3)
    +#if (__GNUC__ == 3 && __GNUC_MINOR__ >= 2) || (__GNUC__ > 3)
    extern int pthread_once (pthread_once_t *__once_control,
    void (*__init_routine) (void))
    __attribute((weak));

  4. Benjamin Müller Says:

    Or just prefix ./configure with

    LDFLAGS=-pthread ./configure […]

    Worked fine with me

    Greetings

    b!

Leave a Reply