bbonev / bpfmon

BPF based visual packet rate monitor
GNU General Public License v2.0
21 stars 1 forks source link

Build from source instructions not working on Ubuntu 20.04.05 #2

Closed KoenDG closed 1 year ago

KoenDG commented 1 year ago

On a fresh VM I tried installing building from source but it doesn't work.

Steps I took, from the readme:

sudo apt install git build-essential pkg-config -y
git clone https://github.com/bbonev/yascreen
cd yascreen
make -j
sudo make install
cd ..
git clone https://github.com/bbonev/bpfmon
cd bpfmon
make -j

1/ For yascreen, the compile also needed the go-md2man package installed.

2/ Compiling yascreen gave this:

$ sudo make install
install -Ds -m 0644 -t /usr/local/lib/ libyascreen.a
install -D -m 0644 -t /usr/local/lib//pkgconfig/ yascreen.pc
ln -fs libyascreen.so.0.0.0 /usr/local/lib/libyascreen.so.0
ln -fs libyascreen.so.0 /usr/local/lib/libyascreen.so
install -Ds -m 0644 -t /usr/local/lib/ libyascreen.so.0.0.0
install -D -m 0644 -t /usr/local/include/ yascreen.h
install -D -m 0644 yascreen.3 /usr/local/share/man/man3/yascreen.3

3/ For bpfmon, I'm getting this output:

~/git/bpfmon$ make -j
cc -O3   -I/usr/local/include/  -Wall -Wextra -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 --std=gnu89 -fPIE -flto -c bpfmon.c -o bpfmon.o
cc -O3   -I/usr/local/include/  -Wall -Wextra -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 --std=gnu89 -fPIE -flto -c psort.c -o psort.o
cc -O3   -I/usr/local/include/  -Wall -Wextra -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 --std=gnu89 -fPIE -flto  -fPIE -pie -o psort psort.o  -L/usr/local/lib/ -lyascreen -lpcap
cc -O3   -I/usr/local/include/  -Wall -Wextra -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 --std=gnu89 -fPIE -flto  -fPIE -pie -o bpfmon bpfmon.o  -L/usr/local/lib/ -lyascreen -lpcap
/usr/bin/ld: /tmp/psort.2VWwaS.ltrans0.ltrans.o: in function `main':
<artificial>:(.text.startup+0x3ed): undefined reference to `yascreen_getch_to'
/usr/bin/ld: <artificial>:(.text.startup+0x1e31): undefined reference to `yascreen_feed'
collect2: error: ld returned 1 exit status
make: *** [Makefile:78: psort] Error 1
make: *** Waiting for unfinished jobs....
/usr/bin/ld: /tmp/bpfmon.5pVMlq.ltrans0.ltrans.o: in function `main':
<artificial>:(.text.startup+0x51d): undefined reference to `yascreen_getch_to'
/usr/bin/ld: <artificial>:(.text.startup+0x1332): undefined reference to `yascreen_feed'
collect2: error: ld returned 1 exit status
make: *** [Makefile:72: bpfmon] Error 1

No idea what this means.

bbonev commented 1 year ago

[I am guessing here, I don't have an Ubnutu 20.04 handy to check]

Most probably an old gcc does not properly support the combination between dynamic library symbol versioning and flto. Symbol versioning in the library was introduced recently and is not fully tested with old compilers.

You can try rebuilding yascreen with:

make -j re NO_FLTO=1

or in case the above does not work with:

make -j re NO_VERSIONED=1

then make install and then retry building bpfmon (don't forget to make clean first)...

P.s. please close the issue, in case the above works for you.

bbonev commented 1 year ago

I could verify - my guess was right... closing.