install.package(ncdf4) failure

This is on a Mac running Big Sur. My XCode is up-to-date and netcdf4 include files and libraries are installed using MacPorts in /opt/local/{include,lib}. nc-config finds these.

I'm getting the following error message when I run
install.packages(ncdf4). the error reads

checking whether the C compiler works... no
configure: error: in /private/var/folders/dg/18_vnn9n29b_1cj7xkgj9sx00000gn/T/Rtmp84SVp1/R.INSTALL5d5489ba89/ncdf4': configure: error: C compiler cannot create executables See config.log' for more details
ERROR: configuration failed for package ‘ncdf4’

  • removing ‘/Users/whd/Library/R/x86_64/4.1/library/ncdf4’
    Warning in install.packages :
    installation of package ‘ncdf4’ had non-zero exit status

Sorry for such a newbie question, but I can't find config.log. Any help?

TIA