title: Error in Rcpp::sourceCpp(): Error 1 occurred building shared library
body: <p>I am trying to use the <code>mixl</code> package in R for discrete choice modelling. <code>mixl</code> includes a pre-compiler that takes a model specification written in plain text, and converts it to a C++ utility function callable from R.</p>
  
  <p>I run R in Windows 10. I have installed the <code>Rtools</code> successfully and added the R executable path (<em>C:\Program Files\R\R-3.6.1\bin</em>) into the environment variables list.</p>
  
  <pre><code>&gt; find_rtools()
  [1] TRUE
  
  &gt; install.Rtools(check = T)
  No need to install Rtools - You've got the relevant version of Rtools installed
  </code></pre>
  
  <p>I have installed the <code>Rcpp</code> package but when running the following code</p>
  
  <pre><code>library(mixl)
  data("Train", package = "mlogit")
  Train$ID &lt;- Train$id
  Train$CHOICE &lt;- as.numeric(Train$choice)
  mixl_test &lt;- "
  ASC_B_RND &lt;- @ASC_B + draw_1*@SIGMA_B;
  TIME_A_RND &lt;- @B_timeA + draw_2*@SIG_time;
  TIME_B_RND &lt;- @B_timeB + draw_2*@SIG_time;
  U_PT &lt;- @B_price*$price_A/1000 + TIME_A_RND*$time_A/60 + @B_change*$change_A;
  U_Car &lt;- ASC_B_RND + (@B_price*$price_B/1000 + TIME_B_RND*$time_B/60);
  "
  model_spec &lt;- specify_model(mixl_test, Train)
  </code></pre>
  
  <p>the following error message comes up.</p>
  
  <pre><code>&gt; C:/Rtools/mingw_64/bin/g++  -std=gnu++11 -I"C:/PROGRA~1/R/R-36~1.1/include" -DNDEBUG -I"C:/Users/takaa/Documents/R/win-library/3.6/mixl/include"  -I"C:/Users/takaa/Documents/R/win-library/3.6/Rcpp/include" -I"C:/Users/takaa/AppData/Local/Temp/RtmpOks2bQ/sourceCpp-x86_64-w64-mingw32-1.0.2"     -fopenmp   -O2 -Wall  -mtune=generic -c file2fbc33473a13.cpp -o file2fbc33473a13.o
  file2fbc33473a13.cpp: In function 'void utilityFunction(Rcpp::NumericVector, UF_args2&amp;)':
  file2fbc33473a13.cpp:127:1: error: 'ASC_B_RND' was not declared in this scope
   ASC_B_RND &lt;- ASC_B + draw[0]*SIGMA_B;
  
  &gt; ^
  &gt; 
  &gt; file2fbc33473a13.cpp:128:1: error: 'TIME_A_RND' was not declared in this scope
   TIME_A_RND &lt;- B_timeA + draw[1]*SIG_time;
  &gt; 
  &gt; ^
  &gt; 
  &gt; file2fbc33473a13.cpp:129:1: error: 'TIME_B_RND' was not declared in this scope
   TIME_B_RND &lt;- B_timeB + draw[1]*SIG_time;
  &gt; 
  &gt; ^
  &gt; 
  &gt; make: *** [C:/PROGRA~1/R/R-36~1.1/etc/x64/Makeconf:215:
  &gt; file2fbc33473a13.o] Error 1 
  &gt; 
  &gt; Error in Rcpp::sourceCpp(code =
  &gt; e1$cpp_code, env = cpp_container) :    Error 1 occurred building
  &gt; shared library.
  &gt; 
  </code></pre>
  
  <p>I believe the questions is similar to [<a href="https://stackoverflow.com/questions/58266286/error-1-occurred-building-shared-library-while-sourcing-cpp-code-inside-r?noredirect=1&amp;lq=1][1]">Error 1 occurred building shared library while sourcing cpp code inside R</a> and [<a href="https://github.com/aidenlab/straw/issues/20][2]" rel="nofollow noreferrer">https://github.com/aidenlab/straw/issues/20][2]</a> but I have rebooted Rstudio and Windows (and nothing changed) and concerning the second question should I change to <code>-std=c++11</code> from <code>-std=gnu++11</code>? Has Anyone faced a similar problem, what is the issue here?   </p>
  
  <p>R version 3.6.1 (2019-07-05) -- "Action of the Toes"
  Copyright (C) 2019 The R Foundation for Statistical Computing
  Platform: x86_64-w64-mingw32/x64 (64-bit)</p>
  
  <p>Thank you!</p>