R – ‘for’ loop initial declarations are only allowed in C99 mode when installing processx package on linux redhat distribution

  c++, install.packages, linux, r, r-library

I want to install the processx library because it is a required package for a BioConductor package I am using. I get the following error when using install.packages("processx")

Error

gcc -g -O2  -Wall tools/px.c -o tools/px
gcc -g -O2  supervisor/supervisor.c supervisor/utils.c 
      -o supervisor/supervisor
supervisor/supervisor.c: In function 'kill_children':
supervisor/supervisor.c:149:5: error: 'for' loop initial declarations are only allowed in C99 mode
     for (int i=0; i<n_children; i++) {
     ^
supervisor/supervisor.c:149:5: note: use option -std=c99 or -std=gnu99 to compile your code

I referred to this post which provides a solution via the withr library. It had worked when I used had similar issues installing the cluster library. I ran

withr::with_makevars(c(PKG_CFLAGS = "-std=c99"), # Use C++ from '99
                     install.packages("processx"), 
                     assignment = "+=")
# Alternatively, I tried 
withr::with_makevars(c(PKG_CFLAGS = "-std=gnu99"), # Use C++ from '99
                     install.packages("processx"), 
                     assignment = "+=")

I received the same error, so I attempted to install the package directly from the command line via

R --no-save <<< "install.packages('processx', repos = 'http://cran.us.r-project.org')"

This had worked when I received the same error when installing ggplot2. I have read about gcc in other stackoverflow posts, but I am not familiar with the process. Any help would be appreciated!

R Session Info

> sessionInfo()
R version 4.0.0 (2020-04-24)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Red Hat Enterprise Linux

Matrix products: default
BLAS/LAPACK: /zapps7/intel_parallel_studio_xe/2020/compilers_and_libraries_2020.0.166/linux/mkl/lib/intel64_lin/libmkl_gf_lp64.so

locale:
[1] C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] withr_2.4.1

loaded via a namespace (and not attached):
[1] compiler_4.0.0 tools_4.0.0

Source: Windows Questions C++

LEAVE A COMMENT