2012-07-14 33 views
3

這是生成日誌,任何人都可以幫忙嗎?未定義的引用'pthread_key_create'

gcc -DHAVE_CONFIG_H -DHAVE_VERSION_H -DLIBRARY_DIR="\"/usr/local/lib\"" -DSBIN_DIR="\"/usr/local/sbin\"" -I. -I.. -I../zmq/include -g -D_REENTRANT -D__EXTENSIONS__ -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGE_FILES -g -O2 -w -pedantic -std=gnu99 -I../../mysql-connector-c-6.0.2-linux-glibc2.3-x86-32bit/include -c -o dbtool.o dbtool.c 
gcc -o dbtool dbtool.o -g -O2 -Wall -W -Wshadow -pedantic -std=gnu99 -Wl,--export-dynamic -ldl -lpthread -lstdc++ -lrt -luuid -L../../mysql-connector-c-6.0.2-linux-glibc2.3-x86-32bit/lib -lmysqlclient -lm 
../../mysql-connector-c-6.0.2-linux-glibc2.3-x86-32bit/lib/libmysqlclient.a(my_thr_init.c.o): In function `my_thread_global_init': 
/export/home2/tmp/cteam/bs/connector-c-32bit/src/mysql-connector-c-6.0.2/mysys/my_thr_init.c:121: undefined reference to `pthread_key_create' 
../../mysql-connector-c-6.0.2-linux-glibc2.3-x86-32bit/lib/libmysqlclient.a(my_thr_init.c.o): In function `my_thread_init': 
/export/home2/tmp/cteam/bs/connector-c-32bit/src/mysql-connector-c-6.0.2/mysys/my_thr_init.c:317: undefined reference to `pthread_getspecific' 
../../mysql-connector-c-6.0.2-linux-glibc2.3-x86-32bit/lib/libmysqlclient.a(my_thr_init.c.o): In function `my_thread_global_init': 
/export/home2/tmp/cteam/bs/connector-c-32bit/src/mysql-connector-c-6.0.2/mysys/my_thr_init.c:335: undefined reference to `pthread_setspecific' 
../../mysql-connector-c-6.0.2-linux-glibc2.3-x86-32bit/lib/libmysqlclient.a(my_thr_init.c.o): In function `my_thread_destroy_mutex': 
/export/home2/tmp/cteam/bs/connector-c-32bit/src/mysql-connector-c-6.0.2/mysys/my_thr_init.c:260: undefined reference to `pthread_getspecific' 
../../mysql-connector-c-6.0.2-linux-glibc2.3-x86-32bit/lib/libmysqlclient.a(my_thr_init.c.o): In function `my_thread_init': 
/export/home2/tmp/cteam/bs/connector-c-32bit/src/mysql-connector-c-6.0.2/mysys/my_thr_init.c:317: undefined reference to `pthread_getspecific' 
/export/home2/tmp/cteam/bs/connector-c-32bit/src/mysql-connector-c-6.0.2/mysys/my_thr_init.c:335: undefined reference to `pthread_setspecific' 
../../mysql-connector-c-6.0.2-linux-glibc2.3-x86-32bit/lib/libmysqlclient.a(my_thr_init.c.o): In function `my_thread_end': 
/export/home2/tmp/cteam/bs/connector-c-32bit/src/mysql-connector-c-6.0.2/mysys/my_thr_init.c:374: undefined reference to `pthread_getspecific' 
/export/home2/tmp/cteam/bs/connector-c-32bit/src/mysql-connector-c-6.0.2/mysys/my_thr_init.c:422: undefined reference to `pthread_setspecific' 
/export/home2/tmp/cteam/bs/connector-c-32bit/src/mysql-connector-c-6.0.2/mysys/my_thr_init.c:407: undefined reference to `pthread_setspecific' 
../../mysql-connector-c-6.0.2-linux-glibc2.3-x86-32bit/lib/libmysqlclient.a(my_thr_init.c.o): In function `_my_thread_var': 
/export/home2/tmp/cteam/bs/connector-c-32bit/src/mysql-connector-c-6.0.2/mysys/my_thr_init.c:428: undefined reference to `pthread_getspecific' 
../../mysql-connector-c-6.0.2-linux-glibc2.3-x86-32bit/lib/libmysqlclient.a(my_thr_init.c.o): In function `my_thread_var_mutex_in_use': 
/export/home2/tmp/cteam/bs/connector-c-32bit/src/mysql-connector-c-6.0.2/mysys/my_thr_init.c:446: undefined reference to `pthread_getspecific' 
../../mysql-connector-c-6.0.2-linux-glibc2.3-x86-32bit/lib/libmysqlclient.a(my_thr_init.c.o): In function `_my_thread_var': 
/export/home2/tmp/cteam/bs/connector-c-32bit/src/mysql-connector-c-6.0.2/mysys/my_thr_init.c:428: undefined reference to `pthread_getspecific' 
+3

我以爲GCC想要'-pthread'而不是'-lpthread' – Flexo 2012-07-14 09:08:41

+0

謝謝flexo,通過你的方式解決問題。 – sureone 2012-07-14 10:12:19

回答

3

您需要 mysql的庫,引入了依賴性後指定的並行線程庫。鏈接語句從左向右進行解析,如果您在引入依賴關係的對象之前指定了庫,它將被丟棄。

+0

謝謝talonmise,它的工作原理。 – sureone 2012-07-14 10:10:11