Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation error: Performing C SOURCE FILE Test CMAKE_HAVE_LIBC_PTHREAD failed #66

Open
morien opened this issue Mar 9, 2022 · 4 comments

Comments

@morien
Copy link

morien commented Mar 9, 2022

System: CentOS 8
uname -a
Linux xxx.xxx.xxx 4.18.0-147.5.1.el8_1.x86_64 #1 SMP Wed Feb 5 02:00:39 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

I've got boost 1.66 (plus devel) and cmake 3.20.2, so I have my dependencies satisfied, but I'm unable to compile, seeing this in my CMakeError.log:

Performing C SOURCE FILE Test CMAKE_HAVE_LIBC_PTHREAD failed with the following output:
Change Dir: /data/metagenomics_apps/taxator-tk/core/bin/CMakeFiles/CMakeTmp

Run Build Command(s):/bin/gmake -f Makefile cmTC_8f709/fast && /bin/gmake  -f CMakeFiles/cmTC_8f709.dir/build.make CMakeFiles/cmTC_8f709.dir/build
gmake[1]: Entering directory '/data/metagenomics_apps/taxator-tk/core/bin/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_8f709.dir/src.c.o
/bin/cc -DCMAKE_HAVE_LIBC_PTHREAD   -o CMakeFiles/cmTC_8f709.dir/src.c.o -c /data/metagenomics_apps/taxator-tk/core/bin/CMakeFiles/CMakeTmp/src.c
Linking C executable cmTC_8f709
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_8f709.dir/link.txt --verbose=1
/bin/cc -rdynamic CMakeFiles/cmTC_8f709.dir/src.c.o -o cmTC_8f709 
CMakeFiles/cmTC_8f709.dir/src.c.o: In function `main':
src.c:(.text+0x2d): undefined reference to `pthread_create'
src.c:(.text+0x39): undefined reference to `pthread_detach'
src.c:(.text+0x45): undefined reference to `pthread_cancel'
src.c:(.text+0x56): undefined reference to `pthread_join'
collect2: error: ld returned 1 exit status
gmake[1]: *** [CMakeFiles/cmTC_8f709.dir/build.make:99: cmTC_8f709] Error 1
gmake[1]: Leaving directory '/data/metagenomics_apps/taxator-tk/core/bin/CMakeFiles/CMakeTmp'
gmake: *** [Makefile:127: cmTC_8f709/fast] Error 2


Source file was:
#include <pthread.h>

static 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: /data/metagenomics_apps/taxator-tk/core/bin/CMakeFiles/CMakeTmp

Run Build Command(s):/bin/gmake -f Makefile cmTC_4c3a1/fast && /bin/gmake  -f CMakeFiles/cmTC_4c3a1.dir/build.make CMakeFiles/cmTC_4c3a1.dir/build
gmake[1]: Entering directory '/data/metagenomics_apps/taxator-tk/core/bin/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_4c3a1.dir/CheckFunctionExists.c.o
/bin/cc   -DCHECK_FUNCTION_EXISTS=pthread_create -o CMakeFiles/cmTC_4c3a1.dir/CheckFunctionExists.c.o -c /usr/share/cmake/Modules/CheckFunctionExists.c
Linking C executable cmTC_4c3a1
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_4c3a1.dir/link.txt --verbose=1
/bin/cc  -DCHECK_FUNCTION_EXISTS=pthread_create -rdynamic CMakeFiles/cmTC_4c3a1.dir/CheckFunctionExists.c.o -o cmTC_4c3a1  -lpthreads 
/bin/ld: cannot find -lpthreads
collect2: error: ld returned 1 exit status
gmake[1]: *** [CMakeFiles/cmTC_4c3a1.dir/build.make:99: cmTC_4c3a1] Error 1
gmake[1]: Leaving directory '/data/metagenomics_apps/taxator-tk/core/bin/CMakeFiles/CMakeTmp'
gmake: *** [Makefile:127: cmTC_4c3a1/fast] Error 2
@fungs
Copy link
Owner

fungs commented Mar 15, 2022

Hey, thanks for reporting this issue! That is a strange error and seems to have nothing to do with taxator-tk itself, but the cmake build system. I currently don't have the time to test myself, so I'm guessing by the error message:

The library to link to for using POSIX threads (pthreads) is not available in the search path. taxator-tk uses multiple CPU cores with threads. Can you look for the library using

find /usr/lib /lib -name libpthread.so

? For me (Ubuntu/Debian) this yields

> find /usr/lib /lib -name libpthread.so
/usr/lib/x86_64-linux-gnu/libpthread.so

> dpkg -S /usr/lib/x86_64-linux-gnu/libpthread.so
libc6-dev:amd64: /usr/lib/x86_64-linux-gnu/libpthread.so

So the latter package contains the libary. However, it should be installed on every modern Linux system, so I suspect that the cmake check simply does not work correctly for some reason.

@fungs
Copy link
Owner

fungs commented Mar 15, 2022

Does the binary package which you can download in the releases section on GitHub work for you?

@morien
Copy link
Author

morien commented Mar 16, 2022

Thanks for responding, I appreciate it.

Find produces this, so the pthreads library is installed:

> find /usr/lib /lib -name libpthread.so
/usr/lib/libpthread.so

I don't know if there's a dpkg equivalent in CentOS that will reproduce the output you have for the second command, but glibc-devel-2.28-189.el8.x86_64 is the equivalent package for libc6-dev, and it is installed.

I'm messing around with the binary (thanks, I didn't realize it was available, I usually compile from source if the conda install fails for a bioinformatic tool like this). I can get the help menu, but I don't seem to have a custom blastdb that's got a taxdump file, even though I have taxonIDs in all my custom blastdbs. So, I'll have to make one that lastal will accept as input before I test out the taxator binary otherwise I'll have to test with the entire NCBI NT, which seems excessive. I'll try this by the end of the week and report back.

@fungs
Copy link
Owner

fungs commented Mar 17, 2022

The format or repacks is pretty simple and well documented. You will find some for download here:

https://nextcloud.bifo.helmholtz-hzi.de/s/kgtfteoQ9LfzQZx (it currently has a certificate error but otherwise works)

and an example on how to build one in this blog post

https://scienceblog.fungs.de/posts/taxator-tk-marine-refpack/

Regarding the error, I will give it a try in a CentOS environment once I've got some time. Could be, that this is an issue with the build system CMake itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants