Search code examples
clinuxcompilationgnu-toolchain

Can't compile tcprstat on CentOS/redhat. Need advice on GNU Toolkit/bzr


I downloaded code ("bzr branch lp:tcprstat" to get the code - 1.5 MB total), but I am unable to compile it. The files that appear in the tcprstat directory are below. I'm quite familiar with the traditional ./configure, make, sudo make install and reasonably IT savvy.

Resolution of the problem (following Mehmet's input).

From this page, http://xcb.freedesktop.org/dist/, I obtained this file:

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

Ran ./configure, make, sudo make install.

The programme still failed to compile with the same error, but further Googling ("centos pthread missing") gave me this page https://www.centos.org/forums/viewtopic.php?t=3517 which contained the sage advice

yum install glibc-static 

(which I did with sudo)

Et Voilà.

Thanks (and congrats :-) ) to Mehmet who collects the 50 bonus points.

p.s. Mehmet, do you have any good guide to static/dynamic linking in Linux?

[Complete explanation of the problem]

I have not been lazy about this (am downloading book as we speak), and I have tried loads of variants of automake, autoconf, make, aclocal, bootstrap and I am stumped. Yes, I've read the README, but the authors seem to think that everyone knows the GNU Toolchain. I've given the details of my most successful effort so far at the bottom of of the post.

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,

I would be v. gratful if somebody could show me how to compile this programme.

========= Inital list of files =============

-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

============= Best effort ===============

run ./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

==== New list of files after running ./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

Then I run ./configure - that seemed to work fine - no errors.

Then I try to run make and it fails - the error is shown.

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]$ 

Solution

  • Installing tcprstat

    For portability and ease of use, we build a single statically linked binary, which can be downloaded and used as-is on 64-bit platforms. At present there is no installation mechanism, so to use tcprstat, you simply need to

    Compiling

    Maybe you missed something at the end of ./configure:

    enter image description here

    sudo apt-get install libpcap-dev
    

    Make sure that you have completed all these steps without getting an error:

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

    Also checkout this bug, it might be helpful.

    This is my funny history :) , it might be also helpful for you:

    enter image description here

    Files in tcprstat/ after compiling:

    enter image description here

    This is my OS information:

    enter image description here

    *This is a VPS from DigitalOcean

    Addition:

    Try to install this library before make:

    sudo apt-get install libpthread-stubs0-dev