Installing rstan on CentOS (processx failing)

I’m trying to install rstan on a CentOS cluster so that I can run map_rect, but I’m running into problems with the installation. It appears it might have less to do with rstan itself though, but one of its dependencies, processx. If anyone has any suggestions on how to remedy this, please let me know! The error message is the following:

* installing *source* package ‘processx’ ...
** package ‘processx’ successfully unpacked and MD5 sums checked
** libs
icc -std=gnu99 -g -O2 -std=c99  -Wall tools/px.c -o tools/px
icc -std=gnu99 -g -O2 -std=c99  supervisor/supervisor.c supervisor/utils.c \
      -o supervisor/supervisor
icc -std=gnu99 -I/share/apps/r/3.4.2/intel/lib64/R/include -DNDEBUG   -I/share/apps/intel/17.0.1/include -I/share/apps/r/3.4.2/intel/lib64/R/include -I/share/apps/intel/17.0.1/mkl/include -I/share/apps/jdk/1.8.0_111/include   -fpic  -g -O2 -std=c99  -c init.c -o init.o
icc -std=gnu99 -I/share/apps/r/3.4.2/intel/lib64/R/include -DNDEBUG   -I/share/apps/intel/17.0.1/include -I/share/apps/r/3.4.2/intel/lib64/R/include -I/share/apps/intel/17.0.1/mkl/include -I/share/apps/jdk/1.8.0_111/include   -fpic  -g -O2 -std=c99  -c poll.c -o poll.o
icc -std=gnu99 -I/share/apps/r/3.4.2/intel/lib64/R/include -DNDEBUG   -I/share/apps/intel/17.0.1/include -I/share/apps/r/3.4.2/intel/lib64/R/include -I/share/apps/intel/17.0.1/mkl/include -I/share/apps/jdk/1.8.0_111/include   -fpic  -g -O2 -std=c99  -c processx-connection.c -o processx-connection.o
icc -std=gnu99 -I/share/apps/r/3.4.2/intel/lib64/R/include -DNDEBUG   -I/share/apps/intel/17.0.1/include -I/share/apps/r/3.4.2/intel/lib64/R/include -I/share/apps/intel/17.0.1/mkl/include -I/share/apps/jdk/1.8.0_111/include   -fpic  -g -O2 -std=c99  -c processx-vector.c -o processx-vector.o
In file included from processx-vector.c(3):
processx-types.h(13): error: identifier "pid_t" is undefined
    pid_t *stor_begin;
    ^

In file included from processx-vector.c(3):
processx-types.h(14): error: identifier "pid_t" is undefined
    pid_t *stor_end;
    ^

In file included from processx-vector.c(3):
processx-types.h(15): error: identifier "pid_t" is undefined
    pid_t *end;
    ^

In file included from processx-vector.c(3):
processx-types.h(24): error: identifier "pid_t" is undefined
  void processx_vector_push_back(processx_vector_t *v, pid_t e);
                                                       ^

In file included from processx-vector.c(3):
processx-types.h(25): error: identifier "pid_t" is undefined
  int processx_vector_find(const processx_vector_t *v, pid_t e, size_t from, size_t *idx);
                                                       ^

In file included from processx-vector.c(3):
processx-types.h(26): error: identifier "pid_t" is undefined
  void processx_vector_rooted_tree(pid_t root, const processx_vector_t *nodes,
                                   ^

processx-vector.c(8): error: identifier "pid_t" is undefined
    v->stor_begin = (pid_t*) R_alloc(alloc_size, sizeof(pid_t));
                     ^

processx-vector.c(8): error: expected an expression
    v->stor_begin = (pid_t*) R_alloc(alloc_size, sizeof(pid_t));
                           ^

processx-vector.c(8): error: expected a ";"
    v->stor_begin = (pid_t*) R_alloc(alloc_size, sizeof(pid_t));
                             ^

processx-vector.c(21): error: identifier "pid_t" is undefined
    pid_t *tmp;
    ^

processx-vector.c(21): error: identifier "tmp" is undefined
    pid_t *tmp;
           ^

processx-vector.c(24): error: expected an expression
    tmp = (pid_t*) S_realloc( (char*) v->stor_begin, size, alloc_size, sizeof(pid_t));
                 ^

processx-vector.c(24): error: expected a ";"
    tmp = (pid_t*) S_realloc( (char*) v->stor_begin, size, alloc_size, sizeof(pid_t));
                   ^

processx-vector.c(34): error: identifier "pid_t" is undefined
  void processx_vector_push_back(processx_vector_t *v, pid_t e) {
                                                       ^

processx-vector.c(57): error: identifier "pid_t" is undefined
  int processx_vector_find(const processx_vector_t *v, pid_t e, size_t from, size_t *idx) {
                                                       ^

processx-vector.c(82): error: identifier "pid_t" is undefined
  void processx_vector_rooted_tree(pid_t root, const processx_vector_t *nodes,
                                   ^

processx-vector.c(95): error: identifier "pid_t" is undefined
        pid_t parent = VECTOR(*parents)[i];
        ^

compilation aborted for processx-vector.c (code 2)
make: *** [processx-vector.o] Error 2
ERROR: compilation failed for package ‘processx’

Might also have to do with using icc. I would compile all the dependencies with g++ or clang++ and even then, there does not seem to be a strong reason to use Intel’s compiler on Stan programs.

Thanks Ben!

Adding this to the ~/.R/Makevars allowed me to install the “processx” dependency:

CFLAGS=-std=gnu11
CXX14 = g++ -std=c++1y
CXX14FLAGS=-O3 -march=native -mtune=native
CXX14FLAGS += -fPIC

However, I now run into a problem specific to rstan (which I’ve looked around on the forums for, but can’t find a solution for):

Installing package into ‘/home/ge31/R/x86_64-centos-linux-gnu-library/3.4’
(as ‘lib’ is unspecified)
trying URL 'https://cloud.r-project.org/src/contrib/rstan_2.18.2.tar.gz'
Content type 'application/x-gzip' length 838052 bytes (818 KB)
==================================================
downloaded 818 KB

* installing *source* package ‘rstan’ ...
** package ‘rstan’ successfully unpacked and MD5 sums checked
** libs
g++ -std=c++1y  -I/share/apps/r/3.4.2/intel/lib64/R/include -DNDEBUG -I"../inst/include" -I"`"/share/apps/r/3.4.2/intel/lib64/R/bin/Rscript" --vanilla -e "cat(system.file('include', 'src', package = 'StanHeaders'))"`" -DBOOST_DISABLE_ASSERTS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -I"/home/ge31/R/x86_64-centos-linux-gnu-library/3.4/Rcpp/include" -I"/home/ge31/R/x86_64-centos-linux-gnu-library/3.4/RcppEigen/include" -I"/home/ge31/R/x86_64-centos-linux-gnu-library/3.4/BH/include" -I"/home/ge31/R/x86_64-centos-linux-gnu-library/3.4/StanHeaders/include" -I/share/apps/intel/17.0.1/include -I/share/apps/r/3.4.2/intel/lib64/R/include -I/share/apps/intel/17.0.1/mkl/include -I/share/apps/jdk/1.8.0_111/include     -O3 -march=native -mtune=native -fPIC -c chains.cpp -o chains.o
In file included from /home/ge31/R/x86_64-centos-linux-gnu-library/3.4/RcppEigen/include/Eigen/Core:96:0,
                 from /home/ge31/R/x86_64-centos-linux-gnu-library/3.4/RcppEigen/include/Eigen/Dense:1,
                 from /home/ge31/R/x86_64-centos-linux-gnu-library/3.4/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:4,
                 from /home/ge31/R/x86_64-centos-linux-gnu-library/3.4/StanHeaders/include/stan/math/prim/mat/fun/mean.hpp:5,
                 from chains.cpp:19:
/share/apps/intel/17.0.1/include/complex:53:3: error: #error "This Intel <complex> is for use only with the Intel C++ compilers!"
 # error "This Intel <complex> is for use only with the Intel C++ compilers!"
   ^~~~~

[similar errors after this]

You need something like CXX14FLAGS += -stdlib=libstdc++ to not use Intel’s headers.

When I add that one, I get the following:

**g++:** **error:** unrecognized command line option ‘ **-stdlib=libstdc++** ’; did you mean ‘ **-static-libstdc++** ’

When I try what it suggests, I get that Intel headers error message again. I’ve been Googling and trying StackOverflow with no luck so far.

I was able to fix this by reverting to icc to compile rstan, even though I needed to use gcc to compile its dependency, processx. Thanks so much for your help Ben!