title: R package installation is successful on all machines but one
body: <p>We are a team working on an R package containing C/C++ code. The package can successfully be installed on all the machines but one. These all run the same version of Mac OS X. I have provided the log files for the installation of the package on my computer (success) and a colleague's computer (error). The package depends on the Rcpp package and the GSL library, both of which were successfully installed on both machines.</p>
  
  <p><strong>My Computer</strong></p>
  
  <pre><code>WARNING: ignoring environment value of R_HOME
  * installing to library '/Users/dejayn/R/x86_64-apple-darwin10.8.0-library/2.15'
  * installing *source* package 'mrenci' ...
  ** libs
  *** arch - x86_64
  /opt/local/bin/g++-mp-4.5 -I/opt/local/lib/R/include -I/opt/local/lib/R/include/x86_64 -DNDEBUG -fopenmp -fopenmp -I/opt/local/include -I"/Users/dejayn/R/x86_64-apple-darwin10.8.0-library/2.15/Rcpp/include"   -fPIC  -pipe -O2 -m64  -c MRMRTree.cc -o MRMRTree.o
  /opt/local/bin/g++-mp-4.5 -I/opt/local/lib/R/include -I/opt/local/lib/R/include/x86_64 -DNDEBUG -fopenmp -fopenmp -I/opt/local/include -I"/Users/dejayn/R/x86_64-apple-darwin10.8.0-library/2.15/Rcpp/include"   -fPIC  -pipe -O2 -m64  -c Matrix.cc -o Matrix.o
  /opt/local/bin/g++-mp-4.5 -I/opt/local/lib/R/include -I/opt/local/lib/R/include/x86_64 -DNDEBUG -fopenmp -fopenmp -I/opt/local/include -I"/Users/dejayn/R/x86_64-apple-darwin10.8.0-library/2.15/Rcpp/include"   -fPIC  -pipe -O2 -m64  -c MiMBuilder.cc -o MiMBuilder.o
  /opt/local/bin/g++-mp-4.5 -I/opt/local/lib/R/include -I/opt/local/lib/R/include/x86_64 -DNDEBUG -fopenmp -fopenmp -I/opt/local/include -I"/Users/dejayn/R/x86_64-apple-darwin10.8.0-library/2.15/Rcpp/include"   -fPIC  -pipe -O2 -m64  -c SymmetricMatrix.cc -o SymmetricMatrix.o
  /opt/local/bin/g++-mp-4.5 -I/opt/local/lib/R/include -I/opt/local/lib/R/include/x86_64 -DNDEBUG -fopenmp -fopenmp -I/opt/local/include -I"/Users/dejayn/R/x86_64-apple-darwin10.8.0-library/2.15/Rcpp/include"   -fPIC  -pipe -O2 -m64  -c adaptor.cc -o adaptor.o
  /opt/local/bin/g++-mp-4.5 -I/opt/local/lib/R/include -I/opt/local/lib/R/include/x86_64 -DNDEBUG -fopenmp -fopenmp -I/opt/local/include -I"/Users/dejayn/R/x86_64-apple-darwin10.8.0-library/2.15/Rcpp/include"   -fPIC  -pipe -O2 -m64  -c memory.cc -o memory.o
  /opt/local/bin/g++-mp-4.5 -I/opt/local/lib/R/include -I/opt/local/lib/R/include/x86_64 -DNDEBUG -fopenmp -fopenmp -I/opt/local/include -I"/Users/dejayn/R/x86_64-apple-darwin10.8.0-library/2.15/Rcpp/include"   -fPIC  -pipe -O2 -m64  -c tools.cc -o tools.o
  /opt/local/bin/g++-mp-4.5 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/opt/local/lib -o mrenci.so MRMRTree.o Matrix.o MiMBuilder.o SymmetricMatrix.o adaptor.o memory.o tools.o /Users/dejayn/R/x86_64-apple-darwin10.8.0-library/2.15/Rcpp/lib/x86_64/libRcpp.a -fopenmp -fopenmp -L/opt/local/lib/R/lib/x86_64 -lR
  installing to /Users/dejayn/R/x86_64-apple-darwin10.8.0-library/2.15/mrenci/libs/x86_64
  ** R
  ** preparing package for lazy loading
  ** testing if installed package can be loaded
  
  * DONE (mrenci)
  </code></pre>
  
  <p><strong>Colleague's Computer</strong></p>
  
  <pre><code>WARNING: ignoring environment value of R_HOME
  * installing to library '/Library/Frameworks/R.framework/Versions/2.15/Resources/library'
  * installing *source* package 'mrenci' ...
  ** libs
  *** arch - x86_64
  g++ -arch x86_64 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include/x86_64 -DNDEBUG  -fopenmp -I/usr/local/include -I"/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include"   -fPIC  -g -O2  -c MRMRTree.cc -o MRMRTree.o
  MRMRTree.cc: In member function 'double* const MRMRTree::bootstrap(unsigned int)':
  MRMRTree.cc:73: warning: iteration variable 'i' is unsigned
  g++ -arch x86_64 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include/x86_64 -DNDEBUG  -fopenmp -I/usr/local/include -I"/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include"   -fPIC  -g -O2  -c Matrix.cc -o Matrix.o
  g++ -arch x86_64 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include/x86_64 -DNDEBUG  -fopenmp -I/usr/local/include -I"/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include"   -fPIC  -g -O2  -c MiMBuilder.cc -o MiMBuilder.o
  MiMBuilder.cc: In member function 'Matrix* const MiMBuilder::createMiM(unsigned int*, unsigned int, unsigned int*, unsigned int)':
  MiMBuilder.cc:102: warning: iteration variable 'i' is unsigned
  g++ -arch x86_64 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include/x86_64 -DNDEBUG  -fopenmp -I/usr/local/include -I"/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include"   -fPIC  -g -O2  -c SymmetricMatrix.cc -o SymmetricMatrix.o
  g++ -arch x86_64 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include/x86_64 -DNDEBUG  -fopenmp -I/usr/local/include -I"/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include"   -fPIC  -g -O2  -c adaptor.cc -o adaptor.o
  g++ -arch x86_64 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include/x86_64 -DNDEBUG  -fopenmp -I/usr/local/include -I"/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include"   -fPIC  -g -O2  -c memory.cc -o memory.o
  g++ -arch x86_64 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include/x86_64 -DNDEBUG  -fopenmp -I/usr/local/include -I"/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include"   -fPIC  -g -O2  -c tools.cc -o tools.o
  g++ -arch x86_64 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/lib -o mrenci.so MRMRTree.o Matrix.o MiMBuilder.o SymmetricMatrix.o adaptor.o memory.o tools.o /Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/lib/x86_64/libRcpp.a -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
  installing to /Library/Frameworks/R.framework/Versions/2.15/Resources/library/mrenci/libs/x86_64
  ** R
  ** preparing package for lazy loading
  ** testing if installed package can be loaded
  Error in dyn.load(file, DLLpath = DLLpath, ...) : 
    unable to load shared object '/Library/Frameworks/R.framework/Versions/2.15/Resources/library/mrenci/libs/x86_64/mrenci.so':
    dlopen(/Library/Frameworks/R.framework/Versions/2.15/Resources/library/mrenci/libs/x86_64/mrenci.so, 6): Symbol not found: _GOMP_critical_name_end
    Referenced from: /Library/Frameworks/R.framework/Versions/2.15/Resources/library/mrenci/libs/x86_64/mrenci.so
    Expected in: flat namespace
   in /Library/Frameworks/R.framework/Versions/2.15/Resources/library/mrenci/libs/x86_64/mrenci.so
  Error: loading failed
  Execution halted
  ERROR: loading failed
  * removing '/Library/Frameworks/R.framework/Versions/2.15/Resources/library/mrenci'
  </code></pre>
  
  <p>At first, the installation on my colleague's computer would result in the compilation of the package for both architectures, upon which g++ complained about an unknown <code>-arch</code> argument. This issue, however, appears to have been mitigated by forcing the targeting of a single architecture <code>x86_64</code>. It is also worth noting that as a result of these errors, all computers now have several versions of R and g++. Is this an issue with the linker? Does the same compiler need to be used for both R and its packages? In the case of my computer, I never explicitly asked for <code>g++-mp-4.5</code> to be used rather than the default g++ (version 4.2), so I figured R automatically detects it.</p>
  
  <p>In case this is of any help, here is what my Makevars contains:</p>
  
  <pre><code>PKG_LIBS=`$(R_HOME)/bin/Rscript -e "Rcpp:::LdFlags()"` $(SHLIB_OPENMP_CFLAGS) -fopenmp
  PKG_CPPFLAGS=$(SHLIB_OPENMP_CXXFLAGS) -fopenmp
  PKG_CFLAGS=$(SHLIB_OPENMP_CFLAGS) -fopenmp
  </code></pre>
  
  <p>The <code>$(SHLIB_OPENMP_*FLAGS)</code> flags seem to be defined only on my computer; <code>-fopenmp</code> flags were explicitly added for the package to work on all the machines.</p>
  
  <p>Has anyone experienced similar issues? Any help would be appreciated.</p>