[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Tips: Compiling OpenLDAP error on Solaris - configure error: pthread.h and pthread_create are not compatible <http://www.openldap.org/faq/data/cache/11.html>



 
    
Title: OpenLDAP Faq-O-Matic: configure: error: pthread.h and pthread_create are not compatible
(Answer) (Category) OpenLDAP Faq-O-Matic : (Category) OpenLDAP Software FAQ : (Category) Installation : (Category) Platform Hints : (Category) Sun Microsystems Solaris :
configure: error: pthread.h and pthread_create are not compatible
Solaris threads (pthreads and lwp) are preemptive and hence are not safe to use with OpenLDAP 1.x.

See also:

  (Xref) Is OpenLDAP thread safe?
  (Xref) Are third party thread packages supported?

Some versions of Solaris are distributed with default C libraries (ie: -lc) which contains bogus pthread functions. The configure script detects these bogus functions as being incompatibility with the <pthread.h> header, but does not attempts to resolve this problem itself. ./configure (with default settings) will exit with the followoing error:
  checking if pthread_create() works... no
  configure: error: pthread.h and pthread_create are not compatible
This problem is viewed as a vendor bug.

User intervention is necessary to work around this vendor bug. OpenLDAP configure must be told not to look for pthread_create in the default C libraries.

env ac_cv_func_pthread_create=no ./configure

Under OpenLDAP 1.2, --with-threads=lwp may be a viable alternative. However, LWP libraries contain in some versions of Solaris apparently do not automatically "reap" detached threads upon exit. This causes significant resource leakage. It is recommended you avoid --with-threads=lwp.

Under OpenLDAP 1.1, --with-threads=lwp option cannot be used with some versions of Solaris. Some versions of Solaris mistakenly define pthread typedefs in inapproriate headers. OpenLDAP 1.1 lwp thread support conflicts with these defines.

OpenLDAP 1.2's thread library no longer mimics the pthread API. However, you run into resource leakage problems noted above.

Another solution is to include the vendor's (or alternative) Pthread libraries in $LIBS.

For sh(1) users:

  LIBS="-lpthread -lposix4"; export LIBS
  ./configure --with-threads
For csh(1) users:
  setenv LIBS "-lpthread -lposix4"
  ./configure --with-threads
This solution is not generally recommended as it will force all applications within the suite (or using it's libraries) to also be linked with the specified libraries.
Solaris 2.6 and 2.7 need additional help to get thread support compiled in as pthread_create is now defined in libc (it wasn't for 2.5.1).
If compiling with gcc, the following needs to appear before ./configure to properly get thread support detected:
  env ac_cv_func_pthread_create=no ol_cv_kthread_flag=no \
      ol_cv_pthread_flag=no ol_cv_pthreads_flag=no \
      ol_cv_thread_flag=no ./configure
If compiling with the Sun C compiler (tested with v5.0), only ac_cv_func_pthread_create and ol_cv_kthread_flag need to be set to "no".

Because pthread_create is in libc for 2.6 and 2.7, configure will try to locate pthread_create first in libc, then with the compiler flag "-kthread" (which will fail with a compiler error causes cc to again locate pthread_create in libc), then with the compiler flag "-pthread", then with the compiler flag "-pthreads", and then with the compiler flag "-thread". In all cases but the first, the compiler rejects the extra argument and tries to link with libc (because we haven't yet tried linking with -pthread). Here's how configure fails:

  configure:3733: checking for pthread_create with -kthread
  configure:3748: gcc -o conftest -O2 -I/opt/TWWfsw/libdb2/include \
    -I/opt/TWWfsw/tcpwrap/include -L/opt/TWWfsw/libdb2/lib \
    -L/opt/TWWfsw/tcpwrap/lib conftest.c -kthread -lresolv -lgen \
    -lnsl -lsocket  1>&5
  gcc: unrecognized option `-kthread'
(note: gcc flags may vary depending configure options selected and specifics of your environment)

So, we help configure along by forcing it to jump straight to "-lpthread" as shown in this configure output:

  checking POSIX thread version... final
  checking for LinuxThreads... no
  checking for pthread_create... (cached) no
  checking for pthread_create with -kthread... (cached) no
  checking for pthread_create with -pthread... (cached) no
  checking for pthread_create with -pthreads... (cached) no
  checking for pthread_create with -thread... (cached) no
  checking for pthread_create with -mt... (cached) no
  checking for pthread_mutex_unlock in -lpthread... no
  checking for pthread_mutex_lock in -lpthread... no
  checking for pthread_mutex_trylock in -lpthread... no
  checking for pthread_create in -lpthread... yes

In Solaris 7 I needed to add following to LDFLAGS, before configuring with Solaris 7 pthreads:
 export LIBS=-lrt; export LIBS
Without this "sched_yield" is not found during linking of serveral modules (e.g. slapd)
[Append to This Answer]
Previous: (Answer) Where are the SunOS 4.x (Solaris 1.x) Hints?
Next: (Answer) What do I do if slapd crashes in REGEX code?
This document is: http://www.openldap.org/faq/index.cgi?file=11
[Search] [Appearance]
Faq-O-Matic 2.636
© Copyright 2000, OpenLDAP Foundation, info@xxxxxxxxxxxx
Google