Installing packages "rgdal", "terra" and "sf"

I needed to do some spatial analysis on R, and I am trying to install the packages “rgdal”, “sf”, “terra”, and “gdalUtils”. I get the following error (ERROR: configuration failed for package ‘rgdal’). I randomly googled and came across the Princeton and Northern Arizona websites for HPC, and they have specific instructions on how to install these packages in R. But they aren’t working on USC HPC. Any help would be appreciated.