I am using


to install the package "DiffBind" on CentOS_7, I got the error:

gcc -I"/opt/common/CentOS_7/R/R-4.0.5/lib64/R/include" -DNDEBUG -D_FILE_OFFSET_BITS=64 -I'/lila/home/lid/R/x86_64-pc-linux-gnu-library/4.0/Rhtslib/include' -I'/admin/opt/common/CentOS_7/R/R-4.0.5/lib64/R/library/Rcpp/include' -I/usr/local/include   -fpic  -g -O2  -c mergeOne.c -o mergeOne.o
mergeOne.c: In function ‘mungeTarget’:
mergeOne.c:341:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
   for (int i=l;i<l+r;i++) {
mergeOne.c:341:3: note: use option -std=c99 or -std=gnu99 to compile your code
make: *** [mergeOne.o] Error 1
ERROR: compilation failed for package ‘DiffBind’

Can anyone tell me what should I do? Thanks


2 Answers 2


You can set a specific compiler in ~/.R/Makevars file, create the folder and write it down in Makevers:

CC = gcc -std=c99


CC = gcc -std=gnu99

The previous answer is correct, in that the compiler wants to be able to use C99 to compile your library.

However, the solution of putting CC = gcc -std=c99 into your ~/.R/Makevars is a little bit blunt, since everything that you now compile not directly from source is going to use the -std=c99 flag. This is a recipe for some confusing and hard to track down error messages. It's a bit like installing everything in your base conda environment and waiting for everything to break.

It's a safer option to use withr, which allows you to specify compiler flags for individual installations, keeping everything nice and neat. It works a bit like the with (or within) function in R which constructs an environment to execute some command in.


    c(PKG_CFLAGS = "-std=c99"), 
    assignment = "+="

It can also be performed directly with BiocManager:

    configure.vars = c("CC" = "gcc", "-std" = "c99")
  • $\begingroup$ Couldn't that be done via the ... argument on BiocManager::install that it is passed to install.packages? BiocManager::install("DiffBind", configure.vars = c("CC" = "gcc", "-std" = "c99") never used it but I think this is the "standard" way. $\endgroup$
    – llrs
    Jun 30, 2022 at 15:20
  • $\begingroup$ @llrs ah, didn't realise that. Thanks, will add to answer! $\endgroup$
    – user438383
    Jun 30, 2022 at 15:22
  • $\begingroup$ I might be wrong. how the variables are passed but I think there is the option to do that via install.packages and by extension BiocManager::install $\endgroup$
    – llrs
    Jun 30, 2022 at 22:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.