[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: Unable to build LMDB on SUSE Linux: undefined reference to pthread_mutexattr_setrobust / pthread_mutex_consistent



Hello,

I am trying to build LMDB libraries from source on SUSE Linux using gcc
4.7.2 to try for an experimental project at work. I am getting some build
errors. I see pthread.h and libpthread.{a/so} installed in /usr/include and
/usr/lib64, respectively. But I do not see these functions in the header file
or in the library. Maybe the pthread library version is old. I am not sure. I
tried searching on the web, but I was not able to understand how to install a
different version of the pthread library (it seems to come packaged with the
OS?). I do not have admin rights so I would try installing in my local area.

Can someone please advise on things I can try to resolve this issue? Thank you for your time and help.

You're not using a released branch of LMDB code. When you use a development branch you're expected to actually know how your development environment works.

(P.S. I had built LMDB successfully on a Mac OS X machine (home computer) without any issues)

$ make
gcc -pthread -O2 -g -W -Wall -Wno-unused-parameter -Wbad-function-cast -Wuninitialized   -c mdb.c
mdb.c: In function ‘mdb_mutex_failed’:
mdb.c:9827:4: warning: implicit declaration of function ‘pthread_mutex_consistent’ [-Wimplicit-function-declaration]
gcc -pthread -O2 -g -W -Wall -Wno-unused-parameter -Wbad-function-cast -Wuninitialized   -c midl.c
ar rs liblmdb.a mdb.o midl.o
ar: creating liblmdb.a
gcc -pthread -O2 -g -W -Wall -Wno-unused-parameter -Wbad-function-cast -Wuninitialized  -fPIC  -c mdb.c -o mdb.lo
mdb.c: In function ‘mdb_mutex_failed’:
mdb.c:9827:4: warning: implicit declaration of function ‘pthread_mutex_consistent’ [-Wimplicit-function-declaration]
gcc -pthread -O2 -g -W -Wall -Wno-unused-parameter -Wbad-function-cast -Wuninitialized  -fPIC  -c midl.c -o midl.lo
gcc  -pthread -shared -o liblmdb.so mdb.lo midl.lo
gcc -pthread -O2 -g -W -Wall -Wno-unused-parameter -Wbad-function-cast -Wuninitialized   -c mdb_stat.c
gcc -pthread -O2 -g -W -Wall -Wno-unused-parameter -Wbad-function-cast -Wuninitialized   mdb_stat.o liblmdb.a  -o mdb_stat
liblmdb.a(mdb.o): In function `mdb_env_setup_locks':
/nfs/pdx/proj/dt/tctg03/pgupta6/lmdb-mdb.master/libraries/liblmdb/mdb.c:4642: undefined reference to `pthread_mutexattr_setrobust'
liblmdb.a(mdb.o): In function `mdb_mutex_failed':
/nfs/pdx/proj/dt/tctg03/pgupta6/lmdb-mdb.master/libraries/liblmdb/mdb.c:9827: undefined reference to `pthread_mutex_consistent'
collect2: error: ld returned 1 exit status
make: *** [mdb_stat] Error 1

My environment is as follows:

$ more /etc/SuSE-release
SUSE Linux Enterprise Server 11 (x86_64)
VERSION = 11
PATCHLEVEL = 2

$ uname -a
Linux 3.0.101-0.7.29.1.8482.4.PTF-default #1 SMP Tue May 5 16:00:34 UTC 2015 () x86_64 x86_64 x86_64 GNU/Linux

SUSE Linux Enterprise Server 11 definitely supports robust mutexes, since they actually list bug fixes for that feature.

https://www.suse.com/support/update/announcement/2013/suse-su-20131852-1.html

But it's possible that the function definitions are hidden or renamed. Look for them in /usr/include/pthread.h and then supply the appropriate preprocessor flags to expose their definitions.

You may need to adjust the LMDB code to use pthread_mutexattr_setrobust_np and pthread_mutex_consistent_np. If you don't know how to do this, stick with the actual release branch.

--
  -- Howard Chu
  CTO, Symas Corp.           http://www.symas.com
  Director, Highland Sun     http://highlandsun.com/hyc/
  Ch