You need to figure out how to communicate to your version of cmake that -lpthread is needed at link time. What I sent works for cmake 3.12.4 running on ubuntu 20.04. You may want to try upgrading your cmake.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
We've been trying to compile smina, and there seems to be a problem in the linking process.
After compilation, when linking, it fails with an error that indicates that pthreads.h wasn't found.
The CMakeFiles/CMakeError.log file in the build/ directory shows the following error:
The cmake command being used is as follows:
Any assistance with this issue is appreciated.
Thank you.
Try adding
target_link_libraries(smina Threads::Threads)
to the end of CMakeLists.txtWe've tried adding the line, but the error persists.
Here's the full CMakeError.log output:
You need to figure out how to communicate to your version of cmake that -lpthread is needed at link time. What I sent works for cmake 3.12.4 running on ubuntu 20.04. You may want to try upgrading your cmake.
We've upgraded cmake to 3.18.1 and the issue persists. We've managed to compile it on Ubuntu as a test, but not on our working environment on CentOS.
Any other ideas to link pthreads with cmake?
Thank you.
Try adding
target_link_libraries(smina pthread)
We tried adding the line, but the problem persists.
As a test, using the code that CMake uses to verify the presence of “pthreads”:
and attempting to compile it, if it’s compiled with “-lpthreads”, as is generated by the smina CMake it outputs an error:
But it succeeds if "-lpthread” is used instead:
Perhaps the problem is that CMake is generating the library’s name incorrectly?
What is the link line that is causing the error (run make -DVERBOSE=1)? Could your pthread library possibly be in a non-standard location?
The solution was compiling a new version of Boost. It seems to be working well now.
Thank you for your quick responses and support.