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?
probably means that the system is trying to install a source file, which requires compilation. That problem won't occur with a binary file installation. Other packages have succeeded most likely because at the time of installation no later source version was available.
Yes. As I've made clear, ( twice), I know that it's trying to compile a source file.
Given that the netcdf4 libraries exist on my computer, and the configuration messages (which I haven't provided, but which I can, if you want) show that it's looking in the correct place for the include files and the libraries, the mystery is why it's not succeeding.
But, if you know of where I can get a binary for this library, I'll happily entertain installing that. Being a newbie, I don't know how to install anything except through the method which is failing, namely, via the command
install.packages("ncdf4")
I'd like to point out that this command has succeeded in installing packages from source for other libraries, so I'm a bit at a loss as to how to proceed.
Perhaps you can answer this question.
It says
See `config.log' for more details
Where is that file? The directories it mentions don't have it, or they've been deleted by the build process.
That executable doesn't exist. There is a /opt/local/bin/clang-12 installed by MacPorts.
The 'system' clang is in /usr/bin/clang (installed by Xcode and its `command line' tools) is version 13, if clang --version is anything to go by.
I symlinked /opt/local/bin/clang-mp-13 to /usr/bin/clang and tried again. It still failed, but asked if I wanted to install the Command Line developer tools. (I have installed these, both through Xcode's command 'Xcode-select --install' and by downloading the package for the command line tools and installing that 'by hand', so to speak), but I'm not going to argue with it, so I said yes. It downloaded and installed them (again).
This failure to see Apple's command line developer tools is a common failure for MacPorts; apparently R's 'install.packages(...)' command suffers the same problem.
This webpage discusses issues related to installing packages on a Mac running Big Sur.
Since I had symlinked /opt/local/bin/clang-mp-13 to /usr/bin/clang, that is what occasioned the message that I needed to download and install Xcode's command line developer tools when I tried install.packages(...) the last time but one. However, the compilation still failed.
I saw that MacPorts had a clang-13 variant, so I tried to install that, but the installation failed because of my symlink in /opt/local/bin. I removed that and tried again, the install of clang-13 succeeded, produced a file /opt/local/bin/clang-mp-13.
I tried
install.packaged("ncdf4")
again, and it succeeded!
So, apparently, the clang version 13 that comes with Apple's Xcode doesn't work, but the one that comes with MacPorts does. The posted PDF says the same about Xcode 13.
The success illustrates why installation from source on macOS can be problematic for most users. Even though it sometimes succeeds, with as much effort as shown, or more, it often fails. There is no advantage to installing from source over the binary versions other than the hours of enjoyment spent trying to understand, as shown here, the source of the problem. My advice to others is always to check the CRAN page for the package for the pre-compiled (binary) version.