Compilation error on Ubuntu but not on MacOS

Hi all,
I have a model that compiles and runs perfectly fine in R on my local MacBook (MacOS 10.15.2 ), but does not compile on a remote running Ubuntu 16.04.6 LTS (which I do not have sudo on). I would be very thankful if anyone is able to point me in the right direction! See below for details.

R command

nig <- stan_model("code/nig.stan", auto_write=TRUE, verbose=TRUE)

nig.stan file

functions {
  // inverse Gaussian log probability density function
  real igauss_lpdf(real x, real phi, real lambda) {
    return -log(2*pi())/2 + log(lambda)/2 - 3*log(x)/2
    - lambda*square(x - phi)/(2*square(phi)*x);
  }
  // Jeffrey's log probability density (up to constant)
  real jeffreys_lpdf(real x) {
    return -3*log(x)/2;
  }
}

data {
  int<lower=1> p;
  int<lower=1> n;
  matrix[n, p] x;
  vector[n] y; 
  vector<lower=0>[p] phi;
  real<lower=0> lambdaf;
  real<lower=0> chi;
  real<lower=0> lambdad;
}

parameters {
  vector[p] beta;
  vector<lower=0>[p] gammasq;
  real<lower=0> tausq;
  real<lower=0> sigmasq;
}

transformed parameters {
  vector<lower=0>[p] gamma = sqrt(gammasq);
  real<lower=0> tau = sqrt(tausq);
  real<lower=0> sigma = sqrt(sigmasq);
  vector<lower=0>[p] betasd = sigma*gamma*tau;
  // vector[n] mu;
  // mu = x*beta;
}

model {
  // priors
  target += jeffreys_lpdf(sigmasq);   
  target += igauss_lpdf(tausq | chi, lambdad);
  for(j in 1:p) {
    target += igauss_lpdf(gammasq[j] | phi[j], lambdaf);
  }
  beta ~ normal(0., betasd);
  
  // likelihood
  y ~ normal(x*beta, sigma);
}

Console output

TRANSLATING MODEL 'nig' FROM Stan CODE TO C++ CODE NOW.
successful in parsing the Stan model 'nig'.
COMPILING THE C++ CODE FOR MODEL 'nig' NOW.
OS: x86_64, linux-gnu; rstan: 2.19.2; Rcpp: 1.0.3; inline: 0.3.15 
 >> setting environment variables: 
PKG_LIBS =  -L'/home/munchmm/Library/R/3.4.2/library/StanHeaders/lib/' -lStanHeaders
PKG_CPPFLAGS =   -I"/home/munchmm/Library/R/3.4.2/library/Rcpp/include/"  -I"/home/munchmm/Library/R/3.4.2/library/RcppEigen/include/"  -I"/home/munchmm/Library/R/3.4.2/library/RcppEigen/include/unsupported"  -I"/home/munchmm/Library/R/3.4.2/library/BH/include" -I"/home/munchmm/Library/R/3.4.2/library/StanHeaders/include/src/"  -I"/home/munchmm/Library/R/3.4.2/library/StanHeaders/include/"  -I"/home/munchmm/Library/R/3.4.2/library/rstan/include" -DEIGEN_NO_DEBUG  -DBOOST_DISABLE_ASSERTS
 >> Program source :

*Omitted this because it was too long*
 
Compilation argument:
 /usr/lib/R/bin/R CMD SHLIB file113954a1fa63a.cpp 2> file113954a1fa63a.cpp.err.txt 
In file included from /home/munchmm/Library/R/3.4.2/library/BH/include/boost/smart_ptr/shared_ptr.hpp:28:0,
                 from /home/munchmm/Library/R/3.4.2/library/BH/include/boost/shared_ptr.hpp:17,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math/prim/mat/fun/LDLT_factor.hpp:7,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math/prim/mat/err/check_ldlt_factor.hpp:6,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math/prim/mat.hpp:34,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math/rev/mat.hpp:12,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math.hpp:4,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/src/stan/model/model_header.hpp:4,
                 from file113954a1fa63a.cpp:8:
/home/munchmm/Library/R/3.4.2/library/BH/include/boost/smart_ptr/detail/shared_count.hpp:355:33: warning: ‘template<class> class std::auto_ptr’ is deprecated [-Wdeprecated-declarations]
     explicit shared_count( std::auto_ptr<Y> & r ): pi_( new sp_counted_impl_p<Y>( r.get() ) )
                                 ^
In file included from /usr/include/c++/5/bits/locale_conv.h:41:0,
                 from /usr/include/c++/5/locale:43,
                 from /home/munchmm/Library/R/3.4.2/library/BH/include/boost/lexical_cast/detail/converter_lexical_streams.hpp:43,
                 from /home/munchmm/Library/R/3.4.2/library/BH/include/boost/lexical_cast/detail/converter_lexical.hpp:54,
                 from /home/munchmm/Library/R/3.4.2/library/BH/include/boost/lexical_cast/try_lexical_convert.hpp:44,
                 from /home/munchmm/Library/R/3.4.2/library/BH/include/boost/lexical_cast.hpp:32,
                 from /home/munchmm/Library/R/3.4.2/library/BH/include/boost/math/tools/convert_from_string.hpp:15,
                 from /home/munchmm/Library/R/3.4.2/library/BH/include/boost/math/constants/constants.hpp:13,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math/prim/scal/fun/constants.hpp:4,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math/rev/core/operator_unary_plus.hpp:7,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math/rev/core.hpp:37,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math/rev/mat.hpp:4,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math.hpp:4,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/src/stan/model/model_header.hpp:4,
                 from file113954a1fa63a.cpp:8:
/usr/include/c++/5/bits/unique_ptr.h:49:28: note: declared here
   template<typename> class auto_ptr;
                            ^
In file included from /home/munchmm/Library/R/3.4.2/library/BH/include/boost/shared_ptr.hpp:17:0,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math/prim/mat/fun/LDLT_factor.hpp:7,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math/prim/mat/err/check_ldlt_factor.hpp:6,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math/prim/mat.hpp:34,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math/rev/mat.hpp:12,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math.hpp:4,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/src/stan/model/model_header.hpp:4,
                 from file113954a1fa63a.cpp:8:
/home/munchmm/Library/R/3.4.2/library/BH/include/boost/smart_ptr/shared_ptr.hpp:256:65: warning: ‘template<class> class std::auto_ptr’ is deprecated [-Wdeprecated-declarations]
 template< class T, class R > struct sp_enable_if_auto_ptr< std::auto_ptr< T >, R >
                                                                 ^
In file included from /usr/include/c++/5/bits/locale_conv.h:41:0,
                 from /usr/include/c++/5/locale:43,
                 from /home/munchmm/Library/R/3.4.2/library/BH/include/boost/lexical_cast/detail/converter_lexical_streams.hpp:43,
                 from /home/munchmm/Library/R/3.4.2/library/BH/include/boost/lexical_cast/detail/converter_lexical.hpp:54,
                 from /home/munchmm/Library/R/3.4.2/library/BH/include/boost/lexical_cast/try_lexical_convert.hpp:44,
                 from /home/munchmm/Library/R/3.4.2/library/BH/include/boost/lexical_cast.hpp:32,
                 from /home/munchmm/Library/R/3.4.2/library/BH/include/boost/math/tools/convert_from_string.hpp:15,
                 from /home/munchmm/Library/R/3.4.2/library/BH/include/boost/math/constants/constants.hpp:13,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math/prim/scal/fun/constants.hpp:4,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math/rev/core/operator_unary_plus.hpp:7,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math/rev/core.hpp:37,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math/rev/mat.hpp:4,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math.hpp:4,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/src/stan/model/model_header.hpp:4,
                 from file113954a1fa63a.cpp:8:
/usr/include/c++/5/bits/unique_ptr.h:49:28: note: declared here
   template<typename> class auto_ptr;
                            ^
In file included from /home/munchmm/Library/R/3.4.2/library/BH/include/boost/shared_ptr.hpp:17:0,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math/prim/mat/fun/LDLT_factor.hpp:7,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math/prim/mat/err/check_ldlt_factor.hpp:6,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math/prim/mat.hpp:34,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math/rev/mat.hpp:12,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math.hpp:4,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/src/stan/model/model_header.hpp:4,
                 from file113954a1fa63a.cpp:8:
/home/munchmm/Library/R/3.4.2/library/BH/include/boost/smart_ptr/shared_ptr.hpp:471:31: warning: ‘template<class> class std::auto_ptr’ is deprecated [-Wdeprecated-declarations]
     explicit shared_ptr( std::auto_ptr<Y> & r ): px(r.get()), pn()
                               ^
In file included from /usr/include/c++/5/bits/locale_conv.h:41:0,
                 from /usr/include/c++/5/locale:43,
                 from /home/munchmm/Library/R/3.4.2/library/BH/include/boost/lexical_cast/detail/converter_lexical_streams.hpp:43,
                 from /home/munchmm/Library/R/3.4.2/library/BH/include/boost/lexical_cast/detail/converter_lexical.hpp:54,
                 from /home/munchmm/Library/R/3.4.2/library/BH/include/boost/lexical_cast/try_lexical_convert.hpp:44,
                 from /home/munchmm/Library/R/3.4.2/library/BH/include/boost/lexical_cast.hpp:32,
                 from /home/munchmm/Library/R/3.4.2/library/BH/include/boost/math/tools/convert_from_string.hpp:15,
                 from /home/munchmm/Library/R/3.4.2/library/BH/include/boost/math/constants/constants.hpp:13,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math/prim/scal/fun/constants.hpp:4,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math/rev/core/operator_unary_plus.hpp:7,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math/rev/core.hpp:37,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math/rev/mat.hpp:4,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math.hpp:4,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/src/stan/model/model_header.hpp:4,
                 from file113954a1fa63a.cpp:8:
/usr/include/c++/5/bits/unique_ptr.h:49:28: note: declared here
   template<typename> class auto_ptr;
                            ^
In file included from /home/munchmm/Library/R/3.4.2/library/BH/include/boost/shared_ptr.hpp:17:0,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math/prim/mat/fun/LDLT_factor.hpp:7,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math/prim/mat/err/check_ldlt_factor.hpp:6,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math/prim/mat.hpp:34,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math/rev/mat.hpp:12,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math.hpp:4,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/src/stan/model/model_header.hpp:4,
                 from file113954a1fa63a.cpp:8:
/home/munchmm/Library/R/3.4.2/library/BH/include/boost/smart_ptr/shared_ptr.hpp:484:22: warning: ‘template<class> class std::auto_ptr’ is deprecated [-Wdeprecated-declarations]
     shared_ptr( std::auto_ptr<Y> && r ): px(r.get()), pn()
                      ^
In file included from /usr/include/c++/5/bits/locale_conv.h:41:0,
                 from /usr/include/c++/5/locale:43,
                 from /home/munchmm/Library/R/3.4.2/library/BH/include/boost/lexical_cast/detail/converter_lexical_streams.hpp:43,
                 from /home/munchmm/Library/R/3.4.2/library/BH/include/boost/lexical_cast/detail/converter_lexical.hpp:54,
                 from /home/munchmm/Library/R/3.4.2/library/BH/include/boost/lexical_cast/try_lexical_convert.hpp:44,
                 from /home/munchmm/Library/R/3.4.2/library/BH/include/boost/lexical_cast.hpp:32,
                 from /home/munchmm/Library/R/3.4.2/library/BH/include/boost/math/tools/convert_from_string.hpp:15,
                 from /home/munchmm/Library/R/3.4.2/library/BH/include/boost/math/constants/constants.hpp:13,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math/prim/scal/fun/constants.hpp:4,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math/rev/core/operator_unary_plus.hpp:7,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math/rev/core.hpp:37,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math/rev/mat.hpp:4,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math.hpp:4,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/src/stan/model/model_header.hpp:4,
                 from file113954a1fa63a.cpp:8:
/usr/include/c++/5/bits/unique_ptr.h:49:28: note: declared here
   template<typename> class auto_ptr;
                            ^
In file included from /home/munchmm/Library/R/3.4.2/library/BH/include/boost/shared_ptr.hpp:17:0,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math/prim/mat/fun/LDLT_factor.hpp:7,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math/prim/mat/err/check_ldlt_factor.hpp:6,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math/prim/mat.hpp:34,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math/rev/mat.hpp:12,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math.hpp:4,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/src/stan/model/model_header.hpp:4,
                 from file113954a1fa63a.cpp:8:
/home/munchmm/Library/R/3.4.2/library/BH/include/boost/smart_ptr/shared_ptr.hpp:567:34: warning: ‘template<class> class std::auto_ptr’ is deprecated [-Wdeprecated-declarations]
     shared_ptr & operator=( std::auto_ptr<Y> & r )
                                  ^
In file included from /usr/include/c++/5/bits/locale_conv.h:41:0,
                 from /usr/include/c++/5/locale:43,
                 from /home/munchmm/Library/R/3.4.2/library/BH/include/boost/lexical_cast/detail/converter_lexical_streams.hpp:43,
                 from /home/munchmm/Library/R/3.4.2/library/BH/include/boost/lexical_cast/detail/converter_lexical.hpp:54,
                 from /home/munchmm/Library/R/3.4.2/library/BH/include/boost/lexical_cast/try_lexical_convert.hpp:44,
                 from /home/munchmm/Library/R/3.4.2/library/BH/include/boost/lexical_cast.hpp:32,
                 from /home/munchmm/Library/R/3.4.2/library/BH/include/boost/math/tools/convert_from_string.hpp:15,
                 from /home/munchmm/Library/R/3.4.2/library/BH/include/boost/math/constants/constants.hpp:13,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math/prim/scal/fun/constants.hpp:4,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math/rev/core/operator_unary_plus.hpp:7,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math/rev/core.hpp:37,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math/rev/mat.hpp:4,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math.hpp:4,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/src/stan/model/model_header.hpp:4,
                 from file113954a1fa63a.cpp:8:
/usr/include/c++/5/bits/unique_ptr.h:49:28: note: declared here
   template<typename> class auto_ptr;
                            ^
In file included from /home/munchmm/Library/R/3.4.2/library/BH/include/boost/shared_ptr.hpp:17:0,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math/prim/mat/fun/LDLT_factor.hpp:7,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math/prim/mat/err/check_ldlt_factor.hpp:6,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math/prim/mat.hpp:34,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math/rev/mat.hpp:12,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math.hpp:4,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/src/stan/model/model_header.hpp:4,
                 from file113954a1fa63a.cpp:8:
/home/munchmm/Library/R/3.4.2/library/BH/include/boost/smart_ptr/shared_ptr.hpp:576:34: warning: ‘template<class> class std::auto_ptr’ is deprecated [-Wdeprecated-declarations]
     shared_ptr & operator=( std::auto_ptr<Y> && r )
                                  ^
In file included from /usr/include/c++/5/bits/locale_conv.h:41:0,
                 from /usr/include/c++/5/locale:43,
                 from /home/munchmm/Library/R/3.4.2/library/BH/include/boost/lexical_cast/detail/converter_lexical_streams.hpp:43,
                 from /home/munchmm/Library/R/3.4.2/library/BH/include/boost/lexical_cast/detail/converter_lexical.hpp:54,
                 from /home/munchmm/Library/R/3.4.2/library/BH/include/boost/lexical_cast/try_lexical_convert.hpp:44,
                 from /home/munchmm/Library/R/3.4.2/library/BH/include/boost/lexical_cast.hpp:32,
                 from /home/munchmm/Library/R/3.4.2/library/BH/include/boost/math/tools/convert_from_string.hpp:15,
                 from /home/munchmm/Library/R/3.4.2/library/BH/include/boost/math/constants/constants.hpp:13,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math/prim/scal/fun/constants.hpp:4,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math/rev/core/operator_unary_plus.hpp:7,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math/rev/core.hpp:37,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math/rev/mat.hpp:4,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math.hpp:4,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/src/stan/model/model_header.hpp:4,
                 from file113954a1fa63a.cpp:8:
/usr/include/c++/5/bits/unique_ptr.h:49:28: note: declared here
   template<typename> class auto_ptr;
                            ^
In file included from /home/munchmm/Library/R/3.4.2/library/BH/include/boost/shared_ptr.hpp:17:0,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math/prim/mat/fun/LDLT_factor.hpp:7,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math/prim/mat/err/check_ldlt_factor.hpp:6,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math/prim/mat.hpp:34,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math/rev/mat.hpp:12,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math.hpp:4,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/src/stan/model/model_header.hpp:4,
                 from file113954a1fa63a.cpp:8:
/home/munchmm/Library/R/3.4.2/library/BH/include/boost/smart_ptr/shared_ptr.hpp: In member function ‘boost::shared_ptr<T>& boost::shared_ptr<T>::operator=(std::auto_ptr<_Up>&&)’:
/home/munchmm/Library/R/3.4.2/library/BH/include/boost/smart_ptr/shared_ptr.hpp:578:38: warning: ‘template<class> class std::auto_ptr’ is deprecated [-Wdeprecated-declarations]
         this_type( static_cast< std::auto_ptr<Y> && >( r ) ).swap( *this );
                                      ^
In file included from /usr/include/c++/5/bits/locale_conv.h:41:0,
                 from /usr/include/c++/5/locale:43,
                 from /home/munchmm/Library/R/3.4.2/library/BH/include/boost/lexical_cast/detail/converter_lexical_streams.hpp:43,
                 from /home/munchmm/Library/R/3.4.2/library/BH/include/boost/lexical_cast/detail/converter_lexical.hpp:54,
                 from /home/munchmm/Library/R/3.4.2/library/BH/include/boost/lexical_cast/try_lexical_convert.hpp:44,
                 from /home/munchmm/Library/R/3.4.2/library/BH/include/boost/lexical_cast.hpp:32,
                 from /home/munchmm/Library/R/3.4.2/library/BH/include/boost/math/tools/convert_from_string.hpp:15,
                 from /home/munchmm/Library/R/3.4.2/library/BH/include/boost/math/constants/constants.hpp:13,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math/prim/scal/fun/constants.hpp:4,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math/rev/core/operator_unary_plus.hpp:7,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math/rev/core.hpp:37,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math/rev/mat.hpp:4,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math.hpp:4,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/src/stan/model/model_header.hpp:4,
                 from file113954a1fa63a.cpp:8:
/usr/include/c++/5/bits/unique_ptr.h:49:28: note: declared here
   template<typename> class auto_ptr;
                            ^
In file included from /home/munchmm/Library/R/3.4.2/library/BH/include/boost/random/detail/integer_log2.hpp:19:0,
                 from /home/munchmm/Library/R/3.4.2/library/BH/include/boost/random/detail/int_float_pair.hpp:26,
                 from /home/munchmm/Library/R/3.4.2/library/BH/include/boost/random/exponential_distribution.hpp:27,
                 from /home/munchmm/Library/R/3.4.2/library/BH/include/boost/random/gamma_distribution.hpp:25,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math/prim/mat/prob/dirichlet_rng.hpp:5,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math/prim/mat.hpp:292,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math/rev/mat.hpp:12,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math.hpp:4,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/src/stan/model/model_header.hpp:4,
                 from file113954a1fa63a.cpp:8:
/home/munchmm/Library/R/3.4.2/library/BH/include/boost/pending/integer_log2.hpp: At global scope:
/home/munchmm/Library/R/3.4.2/library/BH/include/boost/pending/integer_log2.hpp:7:89: note: #pragma message: This header is deprecated. Use <boost/integer/integer_log2.hpp> instead.
In file included from /home/munchmm/Library/R/3.4.2/library/BH/include/boost/fusion/functional/invocation/detail/that_ptr.hpp:13:0,
                 from /home/munchmm/Library/R/3.4.2/library/BH/include/boost/fusion/functional/invocation/invoke.hpp:52,
                 from /home/munchmm/Library/R/3.4.2/library/BH/include/boost/fusion/functional/adapter/fused.hpp:17,
                 from /home/munchmm/Library/R/3.4.2/library/BH/include/boost/fusion/functional/generation/make_fused.hpp:13,
                 from /home/munchmm/Library/R/3.4.2/library/BH/include/boost/fusion/include/make_fused.hpp:11,
                 from /home/munchmm/Library/R/3.4.2/library/BH/include/boost/numeric/odeint/util/resize.hpp:28,
                 from /home/munchmm/Library/R/3.4.2/library/BH/include/boost/numeric/odeint/util/state_wrapper.hpp:26,
                 from /home/munchmm/Library/R/3.4.2/library/BH/include/boost/numeric/odeint/util/ublas_wrapper.hpp:33,
                 from /home/munchmm/Library/R/3.4.2/library/BH/include/boost/numeric/odeint.hpp:25,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math/prim/arr/functor/integrate_ode_rk45.hpp:17,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math/prim/arr.hpp:46,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math/prim/mat.hpp:344,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math/rev/mat.hpp:12,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math.hpp:4,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/src/stan/model/model_header.hpp:4,
                 from file113954a1fa63a.cpp:8:
/home/munchmm/Library/R/3.4.2/library/BH/include/boost/get_pointer.hpp:48:40: warning: ‘template<class> class std::auto_ptr’ is deprecated [-Wdeprecated-declarations]
 template<class T> T * get_pointer(std::auto_ptr<T> const& p)
                                        ^
In file included from /usr/include/c++/5/bits/locale_conv.h:41:0,
                 from /usr/include/c++/5/locale:43,
                 from /home/munchmm/Library/R/3.4.2/library/BH/include/boost/lexical_cast/detail/converter_lexical_streams.hpp:43,
                 from /home/munchmm/Library/R/3.4.2/library/BH/include/boost/lexical_cast/detail/converter_lexical.hpp:54,
                 from /home/munchmm/Library/R/3.4.2/library/BH/include/boost/lexical_cast/try_lexical_convert.hpp:44,
                 from /home/munchmm/Library/R/3.4.2/library/BH/include/boost/lexical_cast.hpp:32,
                 from /home/munchmm/Library/R/3.4.2/library/BH/include/boost/math/tools/convert_from_string.hpp:15,
                 from /home/munchmm/Library/R/3.4.2/library/BH/include/boost/math/constants/constants.hpp:13,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math/prim/scal/fun/constants.hpp:4,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math/rev/core/operator_unary_plus.hpp:7,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math/rev/core.hpp:37,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math/rev/mat.hpp:4,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/stan/math.hpp:4,
                 from /home/munchmm/Library/R/3.4.2/library/StanHeaders/include/src/stan/model/model_header.hpp:4,
                 from file113954a1fa63a.cpp:8:
/usr/include/c++/5/bits/unique_ptr.h:49:28: note: declared here
   template<typename> class auto_ptr;
                            ^
Error in dyn.load(libLFile) : 
  unable to load shared object '/tmp/Rtmpg84wPg/file113957a2e6b6b.so':
  /tmp/Rtmpg84wPg/file113957a2e6b6b.so: failed to map segment from shared object

R session info

R version 3.4.4 (2018-03-15)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.6 LTS

Matrix products: default
BLAS: /usr/lib/libblas/libblas.so.3.6.0
LAPACK: /usr/lib/lapack/liblapack.so.3.6.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8       
 [4] LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
[10] LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

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

other attached packages:
 [1] pkgbuild_1.0.3       Rcpp_1.0.3           inline_0.3.15        pInc_0.0.0.9000     
 [5] glmnet_2.0-16        Matrix_1.2-15        cambridge_0.0.0.9000 doParallel_1.0.14   
 [9] iterators_1.0.9      foreach_1.4.4        rstan_2.19.2         ggplot2_2.2.1       
[13] StanHeaders_2.19.0  

loaded via a namespace (and not attached):
 [1] pillar_1.0.1       compiler_3.4.4     plyr_1.8.4         bitops_1.0-6      
 [5] prettyunits_1.0.2  tools_3.4.4        digest_0.6.18      memoise_1.1.0     
 [9] lattice_0.20-38    tibble_1.4.1       gtable_0.2.0       rlang_0.1.6       
[13] cli_1.0.1          rstudioapi_0.7     yaml_2.1.13        mvtnorm_1.0-8     
[17] loo_2.1.0          gridExtra_2.3      withr_2.1.2        caTools_1.17.1    
[21] gtools_3.8.1       devtools_1.13.4    stats4_3.4.4       grid_3.4.4        
[25] R6_2.4.0           processx_3.3.1     gdata_2.18.0       ROCR_1.0-7        
[29] corpcor_1.6.9      callr_3.2.0        magrittr_1.5       gplots_3.0.1.1    
[33] scales_1.0.0       ps_1.3.0           codetools_0.2-15   matrixStats_0.54.0
[37] assertthat_0.2.0   colorspace_1.4-0   KernSmooth_2.23-15 gsl_2.1-6         
[41] lazyeval_0.2.1     munsell_0.5.0      crayon_1.3.4

When I remove the comments in the functions block, it compiles on rstan 19.2 with Ubuntu 16.04.
Please put attention to your formatting in future posts. '*' is removed in your posting due to formatting.

functions {
  
  real igauss_lpdf(real x, real phi, real lambda) {
    return -log(2*pi())/2 + log(lambda)/2 - 3*log(x)/2
    - lambda*square(x - phi)/(2*square(phi)*x);
  }
  
  real jeffreys_lpdf(real x) {
    return -3*log(x)/2;
  }
}

Unfortunately, this doesn’t fix the issue for me. Thanks for the formatting tip.

Apparently the temporary directory I was using wasn’t writable or executable or something. I changed the temporary directory to a directory in my user home and now it works.