标签:连接 enc static lib sniffer cpp roo make hub
按照https://github.com/Qihoo360/mysql-sniffer上的安装方法进行安装,make是报错如下
Linking CXX executable mysql-sniffer /usr/bin/ld: /root/mysql-sniffer/lib/libgthread-2.0.a(gthread-impl.o): undefined reference to symbol ‘pthread_setspecific@@GLIBC_2.2.5‘ //usr/lib64/libpthread.so.0: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status make[2]: *** [bin/mysql-sniffer] Error 1 make[1]: *** [bin/CMakeFiles/mysql-sniffer.dir/all] Error 2 make: *** [all] Error 2
网上查询原因是:
pthread 库不是 Linux 系统默认的库,连接时需要使用静态库 libpthread.a,所以在使用pthread_create()创建线程,以及调用 pthread_atfork()函数建立fork处理程序时,需要链接该库。所以在编译中要加 -lpthread参数。
通过查找rdynamic关键字找到文件proj/bin/CMakeFiles/mysql-sniffer.dir/link.txt,并在最后添加了-lpthread,重新make后成功。
/usr/bin/c++ -DENABLE_TCPREASM -O3 -Wall -DENABLE_TCPREASM -O2 CMakeFiles/mysql-sniffer.dir/main.c.o CMakeFiles/mysql-sniffer.dir/mysql-dissector.c.o CMakeFiles/mysql-sniffer.dir/util.c.o CMakeFiles/mysql-sniffer.dir/session.cpp.o CMakeFiles/mysql-sniffer.dir/sniff-config.cpp.o CMakeFiles/mysql-sniffer.dir/sniff-log.cpp.o -o mysql-sniffer -L/root/mysql-sniffer/lib -rdynamic -Wl,-Bstatic -lnidstcpreasm -lnet -lpcap -lglib-2.0 -lgthread-2.0 -Wl,-Bdynamic -lrt -Wl,-Bstatic -lnet -lpcap -lglib-2.0 -lgthread-2.0 -Wl,-Bdynamic -lrt -Wl,-rpath,/root/mysql-sniffer/lib -pthread
tips:
mysql_sniffer该工具好像只要编译出来可执行文件后,复制到其他主机好像也可以使用。
安装mysql_sniffer报错undefined reference to symbol 'pthread_setspecific@@GLIBC_2.2.5'问题
标签:连接 enc static lib sniffer cpp roo make hub
原文地址:https://www.cnblogs.com/MakeInstall/p/10868983.html