How to install BCC on Ubuntu 22.04

To build the toolchain from source, one needs:

LLVM 3.7.1 or newer, compiled with BPF support (default=on)

Clang, built from the same tree as LLVM

cmake (>=3.1), gcc (>=4.7), flex, bison

LuaJIT, if you want Lua support

root@ubuntu:~# cat /etc/*release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04.1 LTS"
PRETTY_NAME="Ubuntu 22.04.1 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.1 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy
root@ubuntu:~# uname -r
5.15.0-60-generic

Install build dependencies

# For Jammy (22.04)
root@ubuntu:~# apt install -y bison build-essential cmake flex git libedit-dev \
libllvm14 llvm-14-dev libclang-14-dev python3 zlib1g-dev libelf-dev libfl-dev python3-distutils

Install and compile BCC

root@ubuntu:~# git clone https://github.com/iovisor/bcc.git
root@ubuntu:~# mkdir bcc/build; cd bcc/build
root@ubuntu:~# cmake ..
root@ubuntu:~# make
root@ubuntu:~# make install
root@ubuntu:~# cmake -DPYTHON_CMD=python3 .. # build python3 binding
root@ubuntu:~# pushd src/python/
root@ubuntu:~# make
root@ubuntu:~# make install
root@ubuntu:~# popd

A first look at BCC

root@ubuntu:~# biolatency 
Tracing block device I/O... Hit Ctrl-C to end.
^C
     usecs               : count     distribution
     0 -> 1          : 0        |                                        |
     2 -> 3          : 0        |                                        |
     4 -> 7          : 0        |                                        |
     8 -> 15         : 0        |                                        |
     16 -> 31        : 0        |                                        |
     32 -> 63        : 0        |                                        |
     64 -> 127       : 0        |                                        |
     128 -> 255      : 1        |****************************************|

Reference