title: "/bin/sh: XX: command not found" error when trying to install development version of R fst package from github
body: <p>I'm trying to install the development version of the <a href="https://github.com/fstpackage/fst" rel="noreferrer"><code>fst</code> package</a> from github. (I want the development version because it maintains column classes when saving data frames, whereas the current released version does not.) </p>
  
  <p>Initially, installation failed due to lack of OpenMP support. I resolved this (I think) by following the steps <a href="http://thecoatlessprofessor.com/programming/openmp-in-r-on-os-x/" rel="noreferrer"><strong>here</strong></a> for R 3.4.0 on OSX. </p>
  
  <p>However, now I'm getting the following error: <code>/bin/sh: XX: command not found</code>. I've already set what are supposed to be the appropriate paths in the <code>~/.R/Makevars</code> file, so I'm not sure what to do next to resolve the error.</p>
  
  <p>Here's my code and output:</p>
  
  <p><strong>First attempt to install <code>fst</code>, before adding OpenMP support</strong></p>
  
  <pre><code>devtools::install_github("fstPackage/fst", ref = "develop")
  </code></pre>
  
  <blockquote>
    <p>* installing *source* package ‘fst’ ...<br>
    ** libs<br>
    clang++ -std=gnu++11 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -fopenmp -I. -Ifstcore -Ifstcore/LZ4 -Ifstcore/ZSTD -Ifstcore/ZSTD/common -Ifstcore/ZSTD/decompress -Ifstcore/ZSTD/compress -I"/Library/Frameworks/R.framework/Versions/3.4/Resources/library/Rcpp/include"
    -I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include   -fPIC  -Wall -g -O2 -c FastStore.cpp -o FastStore.o<br>
    clang: error: unsupported option '-fopenmp'<br>
    make: *** [FastStore.o] Error 1<br>
    ERROR: compilation failed for package ‘fst’</p>
  </blockquote>
  
  <p><strong>Adding OpenMP support</strong></p>
  
  <p>To add OpenMP support, I followed the steps <a href="http://thecoatlessprofessor.com/programming/openmp-in-r-on-os-x/" rel="noreferrer">here</a> for R 3.4.0, including installing <code>gfortran 6.1</code> from <a href="https://gcc.gnu.org/wiki/GFortranBinaries#MacOS-11" rel="noreferrer">here</a> and <code>clang</code> using the pre-built OSX GUI installer provided <a href="https://uofi.app.box.com/v/r-macos-clang-pkg" rel="noreferrer">here</a>. Then, as instructed, I added the following to my <code>~/.R/Makevars</code> file:</p>
  
  <pre><code>CC=/usr/local/clang4/bin/clang
  CXX=/usr/local/clang4/bin/clang++
  CXX11=$CXX
  CXX14=$CXX
  CXX17=$CXX
  CXX1X=$CXX
  LDFLAGS=-L/usr/local/clang4/lib
  </code></pre>
  
  <p><strong>Second attempt to install <code>fst</code></strong></p>
  
  <p>I then ran the installation code again and got the following error:</p>
  
  <pre><code>devtools::install_github("fstPackage/fst", ref = "develop")
  </code></pre>
  
  <blockquote>
    <p>* installing *source* package ‘fst’ ...<br>
    ** libs<br>
    XX -std=gnu++11 -I/Library/Frameworks/R.framework/Resources/include
    -DNDEBUG -fopenmp -I. -Ifstcore -Ifstcore/LZ4 -Ifstcore/ZSTD -Ifstcore/ZSTD/common -Ifstcore/ZSTD/decompress -Ifstcore/ZSTD/compress -I"/Library/Frameworks/R.framework/Versions/3.4/Resources/library/Rcpp/include"
    -I/usr/local/include   -fPIC  -Wall -g -O2 -c FastStore.cpp -o FastStore.o<br>
    /bin/sh: XX: command not found<br>
    make: *** [FastStore.o]<br>
    Error 127 ERROR: compilation failed for package ‘fst’</p>
  </blockquote>
  
  <p>In addition to the errors, I can see that the installation output begins with <code>clang++ -std=gnu++11 ...</code> in the first attempt and <code>XX -std=gnu++11 ...</code> in the second attempt. I'm guessing I need to tell R (or some other program) about the path to <code>clang</code>, but I'm not sure what path is needed or where to put it (and isn't the <code>Makevars</code> file supposed to take care of that?), or whether there are other issues that need to be fixed as well. </p>
  
  <p>Here are some of the particulars about my system:</p>
  
  <p>Macbook Pro, OSX Sierra (version 10.12.5)</p>
  
  <p>RStudio version 1.0.153</p>
  
  <p>R Session Info</p>
  
  <pre><code>R version 3.4.1 (2017-06-30)
  Platform: x86_64-apple-darwin15.6.0 (64-bit)
  Running under: macOS Sierra 10.12.5
  
  Matrix products: default
  BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
  LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib
  
  locale:
  [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
  
  attached base packages:
  [1] stats     graphics  grDevices utils     datasets  methods   base     
  
  loaded via a namespace (and not attached):
   [1] httr_1.2.1      compiler_3.4.1  R6_2.2.2        tools_3.4.1     withr_1.0.2    
   [6] curl_2.8.1      memoise_1.1.0   git2r_0.19.0    digest_0.6.12   devtools_1.13.2
  </code></pre>
  
  <p><strong>UPDATE:</strong> Based on @MarkPlotnick's comment, I changed Makevars to the following:</p>
  
  <pre><code>CC=/usr/local/clang4/bin/clang
  CXX=/usr/local/clang4/bin/clang++
  CXX11=$(CXX)
  CXX14=$(CXX)
  CXX17=$(CXX)
  CXX1X=$(CXX)
  LDFLAGS=-L/usr/local/clang4/lib
  </code></pre>
  
  <p>This resulted in the following error:</p>
  
  <blockquote>
    <p>* installing <em>source</em> package ‘fst’ ...<br>
    ** libs   /Users/eipi10/.R/Makevars:7: *** Recursive variable `CXX' references itself (eventually).  Stop.<br>
    ERROR: compilation failed for package ‘fst’</p>
  </blockquote>