Does it actually fail? I see similar errors and everything works find.

 

Apparently the cmake magic checking for pthread functions looks for both libpthread and libpthreads. Our respective systems have libpthread which if you look below IS were it finds pthread_create, so all should be good.

 

Frank

 

From: Becker, Jeffrey C. (ARC-TN)[InuTeq, LLC] via Devel [mailto:devel@lists.nfs-ganesha.org]
Sent: Thursday, January 7, 2021 2:02 PM
To: devel@lists.nfs-ganesha.org
Subject: [NFS-Ganesha-Devel] Pthread CMake error

 

Hi. I’m trying to build Ganesha 3.4 (latest stable), and CMake output shows the following:

 

-- Looking for pthread.h

-- Looking for pthread.h - found

-- Performing Test CMAKE_HAVE_LIBC_PTHREAD

-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed

-- Looking for pthread_create in pthreads

-- Looking for pthread_create in pthreads - not found

-- Looking for pthread_create in pthread

-- Looking for pthread_create in pthread - found

-- Found Threads: TRUE  

 

However CMake fails with the following in CMakeError.log. Not sure how to proceed. Please advise. Thanks.

 

-Jeff

 

Performing C SOURCE FILE Test CMAKE_HAVE_LIBC_PTHREAD failed with the following output:

Change Dir: /u/jcbecker/ganesha.build/CMakeFiles/CMakeTmp

 

Run Build Command(s):/usr/bin/gmake cmTC_52ec6/fast && /usr/bin/gmake -f CMakeFiles/cmTC_52ec6.dir/build.make CMakeFiles/cmTC_52ec6.dir/build

gmake[1]: Entering directory '/u/jcbecker/ganesha.build/CMakeFiles/CMakeTmp'

Building C object CMakeFiles/cmTC_52ec6.dir/src.c.o

/usr/bin/cc   -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -fno-strict-aliasing -DCMAKE_HAVE_LIBC_PTHREAD   -o CMakeFiles/cmTC_52ec6.dir/src.c.o   -c /u/jcbecker/ganesha.build/CMakeFiles/CMakeTmp/src.c

Linking C executable cmTC_52ec6

/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_52ec6.dir/link.txt --verbose=1

/usr/bin/cc  -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -fno-strict-aliasing -DCMAKE_HAVE_LIBC_PTHREAD    -rdynamic CMakeFiles/cmTC_52ec6.dir/src.c.o  -o cmTC_52ec6 

/usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld: CMakeFiles/cmTC_52ec6.dir/src.c.o: in function `main':

src.c:(.text+0x2d): undefined reference to `pthread_create'

/usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld: src.c:(.text+0x39): undefined reference to `pthread_detach'

/usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld: src.c:(.text+0x45): undefined reference to `pthread_cancel'

/usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld: src.c:(.text+0x56): undefined reference to `pthread_join'

/usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld: src.c:(.text+0x6a): undefined reference to `pthread_atfork'

collect2: error: ld returned 1 exit status

gmake[1]: *** [CMakeFiles/cmTC_52ec6.dir/build.make:104: cmTC_52ec6] Error 1

gmake[1]: Leaving directory '/u/jcbecker/ganesha.build/CMakeFiles/CMakeTmp'

gmake: *** [Makefile:138: cmTC_52ec6/fast] Error 2

 

 

Source file was:

#include <pthread.h>

 

void* test_func(void* data)

{

  return data;

}

 

int main(void)

{

  pthread_t thread;

  pthread_create(&thread, NULL, test_func, NULL);

  pthread_detach(thread);

  pthread_cancel(thread);

  pthread_join(thread, NULL);

  pthread_atfork(NULL, NULL, NULL);

  pthread_exit(NULL);

 

  return 0;

}

 

Determining if the function pthread_create exists in the pthreads failed with the following output:

Change Dir: /u/jcbecker/ganesha.build/CMakeFiles/CMakeTmp

 

Run Build Command(s):/usr/bin/gmake cmTC_3a45d/fast && /usr/bin/gmake -f CMakeFiles/cmTC_3a45d.dir/build.make CMakeFiles/cmTC_3a45d.dir/build

gmake[1]: Entering directory '/u/jcbecker/ganesha.build/CMakeFiles/CMakeTmp'

Building C object CMakeFiles/cmTC_3a45d.dir/CheckFunctionExists.c.o

/usr/bin/cc   -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -fno-strict-aliasing -DCHECK_FUNCTION_EXISTS=pthread_create   -o CMakeFiles/cmTC_3a45d.dir/CheckFunctionExists.c.o   -c /usr/share/cmake/Modules/CheckFunctionExists.c

Linking C executable cmTC_3a45d

/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_3a45d.dir/link.txt --verbose=1

/usr/bin/cc  -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -fno-strict-aliasing -DCHECK_FUNCTION_EXISTS=pthread_create    -rdynamic CMakeFiles/cmTC_3a45d.dir/CheckFunctionExists.c.o  -o cmTC_3a45d  -lpthreads 

/usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld: cannot find -lpthreads

collect2: error: ld returned 1 exit status

gmake[1]: *** [CMakeFiles/cmTC_3a45d.dir/build.make:104: cmTC_3a45d] Error 1

gmake[1]: Leaving directory '/u/jcbecker/ganesha.build/CMakeFiles/CMakeTmp'

gmake: *** [Makefile:138: cmTC_3a45d/fast] Error 2