"undefined reference to 'pthread_create'" error while linking executable
tnguyengel opened this issue · 3 comments
tnguyengel commented
$ make
[ 16%] Building CXX object CMakeFiles/scope.dir/src/run_alstructure.cpp.o
[ 33%] Building CXX object CMakeFiles/scope.dir/src/alstructure.cpp.o
[ 50%] Building CXX object CMakeFiles/scope.dir/src/matmult.cpp.o
[ 66%] Building CXX object CMakeFiles/scope.dir/src/genotype.cpp.o
[ 83%] Building CXX object CMakeFiles/scope.dir/src/storage.cpp.o
[100%] Linking CXX executable scope
CMakeFiles/scope.dir/src/matmult.cpp.o:matmult.cpp:function MatMult::multiply_y_post_fast(Eigen::Matrix<double, -1, -1, 1, -1, -1>&, int, Eigen::Matrix<double, -1, -1, 1, -1, -1>&, bool): error: undefined reference to 'pthread_create'
System Details:
- Kernel version: $ uname -r
3.10.0-957.12.2.el7.x86_64 - OS: CentOS linux 7 (Core)
- Architecture: x86_64
- make v3.82
- cmake v3.14.3
- pthread version: 2.17 I think. I get the following output
$ getconf GNU_LIBPTHREAD_VERSION
NPTL 2.17
alecmchiu commented
Hello,
Can you try adding -pthread
to the line set(CMAKE_CXX_FLAGS "-std=c++0x -O3 -lrt")
to CMakeLists.txt?
It should read set(CMAKE_CXX_FLAGS "-std=c++0x -O3 -lrt -pthread")
after the change.
Best,
Alec
tnguyengel commented
Yes, linking is successful after that
tnguyengel commented
Hi! I noticed this issue is closed. Will there be changes to the makefile so that pthreads is linked by default?