安装配置Dynet2.0.1出现的问题: undefined reference to `pthread_create'
https://github.com/hankcs/multi-criteria-cws/issues/1 使用的版本是2.0.1,这样只能从源代码安装, 安装步骤,作者也介绍了:
我是从源码编译安装的,第一步先安装mkl(可选,大幅提升CPU速度):
http://registrationcenter-download.intel.com/akdlm/irc_nas/tec/11544/l_mkl_2017.3.196.tgz
然后执行如下命令:
#!/usr/bin/env bash
git clone https://github.com/clab/dynet.git
hg clone https://bitbucket.org/eigen/eigen -r 346ecdb # -r NUM specified a known working revision
cd dynet
git checkout 2.0.1
mkdir build
cd build
cmake .. -DEIGEN3_INCLUDE_DIR=../../eigen -DMKL=TRUE -DPYTHON=`which python3` -DMKL_ROOT=/opt/intel/mkl -DBACKEND=cuda
make -j 4
cd python
python ../../setup.py build --build-dir=.. --skip-build install
不过中间遇到了问题:
在cmake的时候,提示错误:
[ 74%] Building CXX object dynet/CMakeFiles/dynet.dir/
weight-decay.cc.o
Linking CXX shared library libgdynet.so
[ 74%] Built target gdynet
Linking CXX shared library libdynet.so
[ 74%] Built target dynet
make: *** [all] Error 2
Here is the complete error-log:
Determining if the pthread_create exist failed with the following output:
Change Dir: /DATA/USERS/irshad/
seqlearning/dynet/build/
CMakeFiles/CMakeTmp
Run Build Command:/usr/bin/make "cmTryCompileExec953060340/
fast"
/usr/bin/make -f CMakeFiles/
cmTryCompileExec953060340.dir/
build.make CMakeFiles/
cmTryCompileExec953060340.dir/
build
make[1]: Entering directory `/DATA/USERS/irshad/
seqlearning/dynet/build/
CMakeFiles/CMakeTmp'
/usr/bin/cmake -E cmake_progress_report /DATA/USERS/irshad/
seqlearning/dynet/build/
CMakeFiles/CMakeTmp/CMakeFiles 1
Building C object CMakeFiles/
cmTryCompileExec953060340.dir/
CheckSymbolExists.c.o
/usr/bin/cc -o CMakeFiles/
cmTryCompileExec953060340.dir/
CheckSymbolExists.c.o -c /DATA/USERS/irshad/
seqlearning/dynet/build/
CMakeFiles/CMakeTmp/
CheckSymbolExists.c
Linking C executable cmTryCompileExec953060340
/usr/bin/cmake -E cmake_link_script CMakeFiles/
cmTryCompileExec953060340.dir/
link.txt --verbose=1
/usr/bin/cc CMakeFiles/
cmTryCompileExec953060340.dir/
CheckSymbolExists.c.o -o cmTryCompileExec953060340 -rdynamic
CMakeFiles/
cmTryCompileExec953060340.dir/
CheckSymbolExists.c.o: In function `main':
CheckSymbolExists.c:(.text+
0x16): undefined reference to `pthread_create'
collect2: error: ld returned 1 exit status
make[1]: *** [cmTryCompileExec953060340] Error 1
make[1]: Leaving directory `/DATA/USERS/irshad/
seqlearning/dynet/build/
CMakeFiles/CMakeTmp'
make: *** [cmTryCompileExec953060340/
fast] Error 2
File /DATA/USERS/irshad/
seqlearning/dynet/build/
CMakeFiles/CMakeTmp/
CheckSymbolExists.c:
/* */
#include <pthread.h>
int main(int argc, char** argv)
{
(void)argv;
#ifndef pthread_create
return ((int*)(&pthread_create))[
argc];
#else
(void)argc;
return 0;
#endif
}
Determining if the function pthread_create exists in the pthreads failed with the following output:
Change Dir: /DATA/USERS/irshad/
seqlearning/dynet/build/
CMakeFiles/CMakeTmp
Run Build Command:/usr/bin/make "cmTryCompileExec4252231607/
fast"
/usr/bin/make -f CMakeFiles/
cmTryCompileExec4252231607.
dir/build.make CMakeFiles/
cmTryCompileExec4252231607.
dir/build
make[1]: Entering directory `/DATA/USERS/irshad/
seqlearning/dynet/build/
CMakeFiles/CMakeTmp'
/usr/bin/cmake -E cmake_progress_report /DATA/USERS/irshad/
seqlearning/dynet/build/
CMakeFiles/CMakeTmp/CMakeFiles 1
Building C object CMakeFiles/
cmTryCompileExec4252231607.
dir/CheckFunctionExists.c.o
/usr/bin/cc -DCHECK_FUNCTION_EXISTS=
pthread_create -o CMakeFiles/
cmTryCompileExec4252231607.
dir/CheckFunctionExists.c.o -c /usr/share/cmake-2.8/Modules/
CheckFunctionExists.c
Linking C executable cmTryCompileExec4252231607
/usr/bin/cmake -E cmake_link_script CMakeFiles/
cmTryCompileExec4252231607.
dir/link.txt --verbose=1
/usr/bin/cc -DCHECK_FUNCTION_EXISTS=
pthread_create CMakeFiles/
cmTryCompileExec4252231607.
dir/CheckFunctionExists.c.o -o cmTryCompileExec4252231607 -rdynamic -lpthreads
/usr/bin/ld: cannot find -lpthreads
collect2: error: ld returned 1 exit status
make[1]: *** [cmTryCompileExec4252231607] Error 1
make[1]: Leaving directory `/DATA/USERS/irshad/
seqlearning/dynet/build/
CMakeFiles/CMakeTmp'
make: *** [cmTryCompileExec4252231607/
fast] Error 2
按照google论坛的说法,是
DEIGEN3_INCLUDE_DIR使用的是相对路径,用绝对路径就好了。
以下是论坛的内容:
Re: undefined reference to `pthread_create' with -DBACKEND=cuda3 名作者发布了 8 个帖子其他收件人: bhatir...@gmail.comHi Bhat,Sorry about the late reply! Could you tell me which operating system you're trying to compile on?Also, could you please delete and recreate the build directory, then run> cmake .. -DEIGEN3_INCLUDE_DIR=/DATA/ USERS/irshad/seqlearning/ eigen/ -DPYTHON=~/ltrc/bin/python -DBACKEND=cuda &> cmake.log> make VERBOSE=1 &> make.logAnd attach the resulting cmake.log and make.log files?GrahamOn Mon, Jan 2, 2017 at 6:18 AM, Bhat Irshad <bhatir...@gmail.com> wrote:Hi,I tried to install dynet with cuda but got the following error:: undefined reference to `pthread_create'cmake .. -DEIGEN3_INCLUDE_DIR=/DATA/USERS/irshad/seqlearning/ eigen/ -DPYTHON=~/ltrc/bin/python -DBACKEND=cuda make -j 12...[ 74%] Building CXX object dynet/CMakeFiles/dynet.dir/weight-decay.cc.o Linking CXX shared library libgdynet.so[ 74%] Built target gdynetLinking CXX shared library libdynet.so[ 74%] Built target dynetmake: *** [all] Error 2Here is the complete error-log:Determining if the pthread_create exist failed with the following output:Change Dir: /DATA/USERS/irshad/seqlearning/dynet/build/ CMakeFiles/CMakeTmp Run Build Command:/usr/bin/make "cmTryCompileExec953060340/fast" /usr/bin/make -f CMakeFiles/cmTryCompileExec953060340.dir/ build.make CMakeFiles/ cmTryCompileExec953060340.dir/ build make[1]: Entering directory `/DATA/USERS/irshad/seqlearning/dynet/build/ CMakeFiles/CMakeTmp' /usr/bin/cmake -E cmake_progress_report /DATA/USERS/irshad/seqlearning/dynet/build/ CMakeFiles/CMakeTmp/CMakeFiles 1 Building C object CMakeFiles/cmTryCompileExec953060340.dir/ CheckSymbolExists.c.o /usr/bin/cc -o CMakeFiles/cmTryCompileExec953060340.dir/ CheckSymbolExists.c.o -c /DATA/USERS/irshad/ seqlearning/dynet/build/ CMakeFiles/CMakeTmp/ CheckSymbolExists.c Linking C executable cmTryCompileExec953060340/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec953060340.dir/ link.txt --verbose=1 /usr/bin/cc CMakeFiles/cmTryCompileExec953060340.dir/ CheckSymbolExists.c.o -o cmTryCompileExec953060340 -rdynamic CMakeFiles/cmTryCompileExec953060340.dir/ CheckSymbolExists.c.o: In function `main': CheckSymbolExists.c:(.text+0x16): undefined reference to `pthread_create' collect2: error: ld returned 1 exit statusmake[1]: *** [cmTryCompileExec953060340] Error 1make[1]: Leaving directory `/DATA/USERS/irshad/seqlearning/dynet/build/ CMakeFiles/CMakeTmp' make: *** [cmTryCompileExec953060340/fast] Error 2 File /DATA/USERS/irshad/seqlearning/dynet/build/ CMakeFiles/CMakeTmp/ CheckSymbolExists.c: /* */#include <pthread.h>int main(int argc, char** argv){(void)argv;#ifndef pthread_createreturn ((int*)(&pthread_create))[argc]; #else(void)argc;return 0;#endif}Determining if the function pthread_create exists in the pthreads failed with the following output:Change Dir: /DATA/USERS/irshad/seqlearning/dynet/build/ CMakeFiles/CMakeTmp Run Build Command:/usr/bin/make "cmTryCompileExec4252231607/fast" /usr/bin/make -f CMakeFiles/cmTryCompileExec4252231607. dir/build.make CMakeFiles/ cmTryCompileExec4252231607. dir/build make[1]: Entering directory `/DATA/USERS/irshad/seqlearning/dynet/build/ CMakeFiles/CMakeTmp' /usr/bin/cmake -E cmake_progress_report /DATA/USERS/irshad/seqlearning/dynet/build/ CMakeFiles/CMakeTmp/CMakeFiles 1 Building C object CMakeFiles/cmTryCompileExec4252231607. dir/CheckFunctionExists.c.o /usr/bin/cc -DCHECK_FUNCTION_EXISTS=pthread_create -o CMakeFiles/ cmTryCompileExec4252231607. dir/CheckFunctionExists.c.o -c /usr/share/cmake-2.8/Modules/ CheckFunctionExists.c Linking C executable cmTryCompileExec4252231607/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec4252231607. dir/link.txt --verbose=1 /usr/bin/cc -DCHECK_FUNCTION_EXISTS=pthread_create CMakeFiles/ cmTryCompileExec4252231607. dir/CheckFunctionExists.c.o -o cmTryCompileExec4252231607 -rdynamic -lpthreads /usr/bin/ld: cannot find -lpthreads