【问题标题】:Can't compile tcprstat on CentOS/redhat. Need advice on GNU Toolkit/bzr无法在 CentOS/redhat 上编译 tcprstat。需要有关 GNU Toolkit/bzr 的建议
【发布时间】:2015-01-30 10:03:01
【问题描述】:

我下载了代码(“bzr branch lp:tcprstat”来获取代码 - 总共 1.5 MB),但我无法编译它。出现在 tcprstat 目录中的文件如下。我非常熟悉传统的 ./configure、make、sudo make install 和合理的 IT 知识。

问题的解决(根据 Mehmet 的意见)。

从这个页面,http://xcb.freedesktop.org/dist/,我得到了这个 文件:

libpthread-stubs-0.3.tar.gz (14-Oct-2009 02:16 267K)

Ran ./configure, make, sudo make install.

程序仍然无法编译并出现同样的错误,但是 进一步谷歌搜索(“centos pthread 缺失”)给了我这个页面 https://www.centos.org/forums/viewtopic.php?t=3517 其中包含圣人的建议

yum install glibc-static 

(我用 sudo 做的)

等等。

感谢(并祝贺 :-))Mehmet,他收集了 50 个奖励积分。

附言Mehmet,您对 Linux 中的静态/动态链接有什么好的指南吗?

[问题的完整说明]

我对此并不懒惰(正如我们所说的那样,我正在下载书),并且我尝试了各种 automake、autoconf、make、aclocal、bootstrap 的变体,我被难住了。是的,我已经阅读了自述文件,但作者似乎认为每个人都知道 GNU 工具链。我在帖子底部给出了迄今为止我最成功的努力的详细信息。

Summary of best efforts (details at bottom)
chmod 755 ./bootstrap
./bootstrap <--- at this point more files appear in the directory
./configure // appeared to work fine
make        // errors -> /usr/bin/ld: cannot find -lpthread -lp,

如果有人能告诉我如何编译这个程序,我将不胜感激。

========= 初始文件列表 =============

-rw-rw-r--. 1 pol pol    38 Jan 30 09:46 AUTHORS
-rw-rw-r--. 1 pol pol   926 Jan 30 09:46 bootstrap
-rw-rw-r--. 1 pol pol     0 Jan 30 09:46 ChangeLog
-rw-rw-r--. 1 pol pol  2643 Jan 30 09:46 configure.ac
-rw-rw-r--. 1 pol pol 35147 Jan 30 09:46 COPYING
drwxrwxr-x. 2 pol pol  4096 Jan 30 09:46 libpcap
-rw-rw-r--. 1 pol pol   922 Jan 30 09:46 Makefile.am
-rw-rw-r--. 1 pol pol   914 Jan 30 09:46 NEWS
-rw-rw-r--. 1 pol pol  2730 Jan 30 09:46 README
drwxrwxr-x. 2 pol pol  4096 Jan 30 09:46 src
-rw-rw-r--. 1 pol pol    81 Jan 30 09:46 TODO

============= 尽力而为===============

运行 ./bootstrap

[pol@localhost tcprstat]$ chmod 755 bootstrap 
[pol@localhost tcprstat]$ ./bootstrap 
configure.ac:80: warning: AC_CONFIG_SUBDIRS: you should use literals
../../lib/autoconf/status.m4:1097: AC_CONFIG_SUBDIRS is expanded from...
configure.ac:80: the top level
configure.ac:80: warning: AC_CONFIG_SUBDIRS: you should use literals
../../lib/autoconf/status.m4:1097: AC_CONFIG_SUBDIRS is expanded from...
configure.ac:80: the top level
configure.ac:80: warning: AC_CONFIG_SUBDIRS: you should use literals
../../lib/autoconf/status.m4:1097: AC_CONFIG_SUBDIRS is expanded from...
configure.ac:80: the top level
configure.ac:31: installing './compile'
configure.ac:26: installing './install-sh'
configure.ac:26: installing './missing'
Makefile.am: installing './INSTALL'
src/Makefile.am: installing './depcomp'
configure.ac:80: warning: AC_CONFIG_SUBDIRS: you should use literals
../../lib/autoconf/status.m4:1097: AC_CONFIG_SUBDIRS is expanded from...
configure.ac:80: the top level
[pol@localhost tcprstat]$ ll
total 336

==== 运行 ./bootstrap 后的新文件列表

-rw-rw-r--. 1 pol pol  39001 Jan 30 10:27 aclocal.m4
-rw-rw-r--. 1 pol pol     38 Jan 30 10:27 AUTHORS
drwxr-xr-x. 2 pol pol   4096 Jan 30 10:27 autom4te.cache
-rwxr-xr-x. 1 pol pol    926 Jan 30 10:27 bootstrap
-rw-rw-r--. 1 pol pol      0 Jan 30 10:27 ChangeLog
lrwxrwxrwx. 1 pol pol     32 Jan 30 10:27 compile -> /usr/share/automake-1.13/compile
-rw-rw-r--. 1 pol pol   3039 Jan 30 10:27 config.h.in
-rwxrwxr-x. 1 pol pol 192216 Jan 30 10:27 configure
-rw-rw-r--. 1 pol pol   2643 Jan 30 10:27 configure.ac
-rw-rw-r--. 1 pol pol  35147 Jan 30 10:27 COPYING
lrwxrwxrwx. 1 pol pol     32 Jan 30 10:27 depcomp -> /usr/share/automake-1.13/depcomp
lrwxrwxrwx. 1 pol pol     32 Jan 30 10:27 INSTALL -> /usr/share/automake-1.13/INSTALL
lrwxrwxrwx. 1 pol pol     35 Jan 30 10:27 install-sh -> /usr/share/automake-1.13/install-sh
drwxrwxr-x. 2 pol pol   4096 Jan 30 10:27 libpcap
-rw-rw-r--. 1 pol pol    922 Jan 30 10:27 Makefile.am
-rw-rw-r--. 1 pol pol  24785 Jan 30 10:27 Makefile.in
lrwxrwxrwx. 1 pol pol     32 Jan 30 10:27 missing -> /usr/share/automake-1.13/missing
-rw-rw-r--. 1 pol pol    914 Jan 30 10:27 NEWS
-rw-rw-r--. 1 pol pol   2730 Jan 30 10:27 README
drwxrwxr-x. 2 pol pol   4096 Jan 30 10:27 src
-rw-rw-r--. 1 pol pol     81 Jan 30 10:27 TODO

然后我运行 ./configure - 似乎工作正常 - 没有错误。

然后我尝试运行 make 但它失败了 - 显示错误。

mv -f .deps/tcprstat_static-stats-hash.Tpo .deps/tcprstat_static-stats-hash.Po
gcc -Wall -Werror -g -pthread -I../libpcap/libpcap-1.1.1/ -g -O2  -static -L../libpcap/libpcap-1.1.1/  -o tcprstat-static tcprstat_static-tcprstat.o tcprstat_static-functions.o tcprstat_static-capture.o tcprstat_static-process-packet.o tcprstat_static-local-addresses.o tcprstat_static-stats.o tcprstat_static-output.o tcprstat_static-stats-hash.o -lpthread -lpcap 
/usr/bin/ld: cannot find -lpthread
/usr/bin/ld: cannot find -lpthread
/usr/bin/ld: cannot find -lc
collect2: error: ld returned 1 exit status
make[2]: *** [tcprstat-static] Error 1
make[2]: Leaving directory `/mysql/tools/tcprstat/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/mysql/tools/tcprstat'
make: *** [all] Error 2
[pol@localhost tcprstat]$ 

【问题讨论】:

    标签: c linux compilation gnu-toolchain


    【解决方案1】:

    安装 tcprstat

    为了便携性和易用性,我们构建了一个静态链接的二进制文件,可以在 64 位平台上按原样下载和使用。目前还没有安装机制,所以要使用tcprstat,你只需要

    编译

    也许你在 ./configure 的末尾遗漏了一些东西:

    sudo apt-get install libpcap-dev
    

    确保您已完成所有这些步骤而没有出现错误:

    bzr checkout lp:tcprstat
    cd tcprstat/
    sh bootstrap
    ./configure
    

    另外结帐this bug,它可能会有所帮助。

    这是我的搞笑history :),也许对你也有帮助:

    编译后tcprstat/中的文件:

    这是我的操作系统信息:

    *这是来自 DigitalOcean 的 VPS

    加法:

    尝试在make之前安装这个库:

    sudo apt-get install libpthread-stubs0-dev
    

    【讨论】:

    • 我知道这一点并且我已经这样做了——但我想自己编译它,最终是为了试验代码。无论如何感谢您的意见。
    • @Vérace 谢谢。我更新了我的答案。也许你能找到一些有用的东西。
    • 再次感谢,但我仍然在原始帖子的底部收到丢失的 lpthread 错误。它为你编译了吗?我在另一台机器上全新安装了 CentOS - 我会试一试。
    • @Vérace 确保您安装了sudo apt-get install libpcap-devsudo apt-get install libpthread-stubs0-dev。请从头开始删除 tcprstat 文件夹。 /usr/bin/ld 找不到错误意味着您缺少 GCC 库。
    • 我使用的是 CentOS,但我确实从源代码安装 - 找不到正确的 yum 包?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-04-14
    • 1970-01-01
    • 2016-04-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多