I have been trying to install a few packages in RStudio Server Pro recently (ex. tmap, sp, etc) and they have mostly resulted in this error message:
surfaceArea.c: In function ‘sarea’:
surfaceArea.c:66:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
for(int j=1;j<(*ny-1);j++){
^
surfaceArea.c:66:3: note: use option -std=c99 or -std=gnu99 to compile your code
surfaceArea.c:67:5: error: ‘for’ loop initial declarations are only allowed in C99 mode
for(int i=1;i<(*nx-1);i++){
^
surfaceArea.c:71:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
for(int tri=0;tri<8;tri++){
^
make: *** [surfaceArea.o] Error 1
ERROR: compilation failed for package ‘sp’
* removing ‘/nfs/cfs/home4/wmjl/wmjlwuh/R/x86_64-pc-linux-gnu-library/4.0/sp’
Warning in install.packages :
installation of package ‘sp’ had non-zero exit status
I have included "dependencies = TRUE" as some have suggested and also tried installing the packages manually to no avail.
Does anyone know how this might be fixed? Thank you so much!
Just to clarify, RStudio is an IDE (Integrated Development Environment) for the R programming language, so the packages get installed in R not RStudio.
About your issue, can you post the complete output you get when you try to install sp?
Installing package into ‘/nfs/cfs/home4/wmjl/wmjlwuh/R/x86_64-pc-linux-gnu-library/4.0’
(as ‘lib’ is unspecified)
also installing the dependencies ‘sf’, ‘units’
trying URL 'https://cran.rstudio.com/src/contrib/sf_0.9-6.tar.gz'
Content type 'application/x-gzip' length 4160758 bytes (4.0 MB)
==================================================
downloaded 4.0 MB
trying URL 'https://cran.rstudio.com/src/contrib/units_0.6-7.tar.gz'
Content type 'application/x-gzip' length 957214 bytes (934 KB)
==================================================
downloaded 934 KB
trying URL 'https://cran.rstudio.com/src/contrib/tmap_3.2.tar.gz'
Content type 'application/x-gzip' length 2952560 bytes (2.8 MB)
==================================================
downloaded 2.8 MB
* installing *source* package ‘units’ ...
** package ‘units’ successfully unpacked and MD5 sums checked
** using staged installation
configure: units: 0.6-7
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether g++ -std=gnu++11 accepts -g... yes
checking how to run the C++ preprocessor... g++ -std=gnu++11 -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for stdbool.h that conforms to C99... yes
checking for _Bool... no
checking for error_at_line... yes
checking for gcc... gcc
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for XML_ParserCreate in -lexpat... yes
checking udunits2.h usability... no
checking udunits2.h presence... no
checking for udunits2.h... no
checking udunits2/udunits2.h usability... no
checking udunits2/udunits2.h presence... no
checking for udunits2/udunits2.h... no
checking for ut_read_xml in -ludunits2... no
configure: error: in `/tmp/RtmpumiLng/R.INSTALL1eb47584fbcd2/units':
configure: error:
--------------------------------------------------------------------------------
Configuration failed because libudunits2.so was not found. Try installing:
* deb: libudunits2-dev (Debian, Ubuntu, ...)
* rpm: udunits2-devel (Fedora, EPEL, ...)
* brew: udunits (OSX)
If udunits2 is already installed in a non-standard location, use:
--configure-args='--with-udunits2-lib=/usr/local/lib'
if the library was not found, and/or:
--configure-args='--with-udunits2-include=/usr/include/udunits2'
if the header was not found, replacing paths with appropriate values.
You can alternatively set UDUNITS2_INCLUDE and UDUNITS2_LIBS manually.
--------------------------------------------------------------------------------
See `config.log' for more details
ERROR: configuration failed for package ‘units’
* removing ‘/nfs/cfs/home4/wmjl/wmjlwuh/R/x86_64-pc-linux-gnu-library/4.0/units’
Warning in install.packages :
installation of package ‘units’ had non-zero exit status
ERROR: dependency ‘units’ is not available for package ‘sf’
* removing ‘/nfs/cfs/home4/wmjl/wmjlwuh/R/x86_64-pc-linux-gnu-library/4.0/sf’
Warning in install.packages :
installation of package ‘sf’ had non-zero exit status
ERROR: dependencies ‘sf’, ‘units’ are not available for package ‘tmap’
* removing ‘/nfs/cfs/home4/wmjl/wmjlwuh/R/x86_64-pc-linux-gnu-library/4.0/tmap’
Warning in install.packages :
installation of package ‘tmap’ had non-zero exit status
The downloaded source packages are in
‘/tmp/RtmpaBz47r/downloaded_packages’
This is the result after I try installing "tmap." Thank you for the clarification, @andresrcs!!
This is a different problem, we like to keep things tidy around here so try to narrow down the scope of your questions to a single issue per topic.
As Nir says, in this case you are missing a system dependency (not an R package) but how to install it depends on the specific operating system that you are using.
Thank you both for your swift responses- I tried installing quite a few dependencies with little success. I'll ask a different question to avoid creating more clutter. Kind regards!