You seem to be missing some crucial development packages. I assume you are using R either from the Ubuntu repositories or from the CRAN repository. In that case
sudo apt install r-base-dev
should fix the issue at hand. Possible sources of binary packages:
- Public RStudio Package Manager: https://packagemanager.rstudio.com/
- Ubuntu: Ubuntu – Details of package r-cran-shazam in focal
- c2d4u: Ubuntu Packages For R - Brief Instructions and https://launchpad.net/~c2d4u.team/+archive/ubuntu/c2d4u4.0+