'How to solve Error installing package lidR in R?

I am using amazon sagemaker notebook instance. And i am trying to install lidR package into R notebook but i got following errors. How can i. Solve it?

Code;

install.packages("lidR")

Error;

installing the dependencies ‘units’, ‘lwgeom’, ‘raster’, ‘sf’, ‘stars’, ‘terra’
    
    
    Warning message in install.packages("lidR"):
    “installation of package ‘units’ had non-zero exit status”
    Warning message in install.packages("lidR"):
    “installation of package ‘terra’ had non-zero exit status”
    Warning message in install.packages("lidR"):
    “installation of package ‘raster’ had non-zero exit status”
    Warning message in install.packages("lidR"):
    “installation of package ‘sf’ had non-zero exit status”
    Warning message in install.packages("lidR"):
    “installation of package ‘lwgeom’ had non-zero exit status”
    Warning message in install.packages("lidR"):
    “installation of package ‘stars’ had non-zero exit status”
    Warning message in install.packages("lidR"):
    “installation of package ‘lidR’ had non-zero exit status”
    Updating HTML index of packages in '.Library'
    
    Making 'packages.html' ...
     done


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source