You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: vignettes/Rcpp-FAQ.Rnw
+95-29Lines changed: 95 additions & 29 deletions
Original file line number
Diff line number
Diff line change
@@ -128,7 +128,7 @@ Specific per-platform notes:
128
128
above detect this and set appropriate flags.
129
129
\item[OS X] users, as noted in the `R Administration' manual \citep[Appendix
130
130
C.4]{R:Administration}, need to install the Apple Developer Tools
131
-
(\textsl{e.g.}, \texttt{Xcode}) (as well as \texttt{gfortran} if \proglang{R} or
131
+
(\textsl{e.g.}, \href{https://itunes.apple.com/us/app/xcode/id497799835?mt=12}{Xcode} (OS X $\le10.8$) or \href{https://developer.apple.com/library/ios/technotes/tn2339/_index.html}{Xcode Command Line Tools} (OS X $\ge10.9$) (as well as \texttt{gfortran} if \proglang{R} or
132
132
Fortran-using packages are to be built); also see \faq{q:OSX} and
133
133
\faq{q:OSXArma} below. Depending on whether on OS X release before or after
134
134
Mavericks is used, different additional installation may be needed. Consult
@@ -433,22 +433,77 @@ complain to its vendor if you are still upset.
433
433
\subsection{I am having problems building Rcpp on OS X, any help ?}
434
434
\label{q:OSX}
435
435
436
-
OS X used to be a little more conservative with compiler versions as Apple
437
-
stuck with gcc-4.2. Following the 'Mavericks' release, it is the opposite as
438
-
only llvm is provide in Xcode. Moreover, OS X currently has two incompatible
439
-
binary modes for the pre- and post-Mavericks world, and CRAN provides
440
-
releases for both variants. Users have to ensure they are not mixing
441
-
releases between packages, and packages and the corresponding R binary package.
436
+
There are three known issues regarding Rcpp build problems on OS X. If you are building packages with RcppArmadillo, there is yet another issue that is addressed separately in \faq{q:OSXArma} below.
442
437
443
-
A helpful post was provided by Brian Ripley in April 2014
444
-
\href{https://stat.ethz.ch/pipermail/r-sig-mac/2014-April/010835.html}{on the
445
-
\code{r-sig-mac} list}, which is generally recommended for OS X-specific questions.
446
-
and further consultation.
438
+
\subsubsection{Lack of a Compiler}
439
+
By default, OS X does not ship with an active compiler. To enable a compiler one must either install \href{https://itunes.apple.com/us/app/xcode/id497799835?mt=12}{Xcode} (OS X $\le10.8$) or \href{https://developer.apple.com/library/ios/technotes/tn2339/_index.html}{Xcode Command Line Tools} (OS X $\ge10.9$). We will focus on the later as the installation requires the use of \texttt{Terminal} and the install size is significantly less than the prior, which is setup using an installer.
447
440
448
-
Another helpful write-up for installation / compilation on OS X Mavericks is
441
+
To install XCode Command Line Tools, one must do the following:
442
+
443
+
\begin{enumerate}
444
+
\item Open \texttt{Terminal} found in \texttt{/Applications/Utilities/}
445
+
\item Type the following:
446
+
<<osx_xcode,engine='bash', eval = F>>=
447
+
$xcode-select--install
448
+
@
449
+
\item Press "Install" on the window that pops up.
450
+
\item After the installation is complete, type the following in \texttt{Terminal} to ensure the installation was successful:
451
+
452
+
<<osx_xcode_gcc,engine='bash', eval = F>>=
453
+
$gcc--version
454
+
@
455
+
\end{enumerate}
456
+
457
+
After major system's update, e.g. 10.11 to 10.12, you may need to accept the terms and licenses associated the the Xcode command line tools prior to being allowed to compile again.
458
+
459
+
To do so, open the \texttt{Terminal} found in \texttt{/Applications/Utilities/} and type:
460
+
461
+
<<osx_xcode_git,engine='bash', eval = F>>=
462
+
$git
463
+
@
464
+
465
+
Press spacebar to move down to the end of the file. There, you should see a prompt asking whether or not you accept the terms via either "Yes" or "No". Enter "Yes" if you agree to the terms to have the command line tools reactivated.
466
+
467
+
\subsubsection{Differing Mac OS X R Versions Leading to Binary Failures}
468
+
469
+
There are currently two distinct versions of R for OS X. The first version is a legacy version meant for Mac OS X 10.6 (Snow Leopard) - 10.8 (Mountain Lion). The second version is for more recent system Mac OS X 10.9 (Mavericks), 10.10 (Yosemite), 10.11 (El Capitan). The distinction comes as a result of a change in the compilers shipped with the operating system. As a result, avoid sending package binaries if it is known that your collaborators are working on older systems as the R binaries for these two versions will not be able to mix.
470
+
471
+
\subsubsection{No OpenMP Support}
472
+
The OS X operating environment lacks the ability to parallelize sections of code using the \href{http://openmp.org/wp/}{OpenMP} standard. As a result, make sure to protect any reference to OpenMP. In this case, protect the inclusion of headers with:
473
+
474
+
<<osx_openmp_header, engine="Rcpp", eval = F>>=
475
+
#ifdef _OPENMP
476
+
#include <omp.h>
477
+
#endif
478
+
@
479
+
480
+
And when one goes to parallelize portions of code use:
481
+
482
+
<<osx_openmp_code, engine="Rcpp", eval = F>>=
483
+
#ifdef _OPENMP
484
+
//multithreadedOpenMPversionofcode
485
+
#else
486
+
//single-threadedversionofcode
487
+
#endif
488
+
@
489
+
490
+
Doing so will enable the parallelization of the process on Linux and Windows. In the event that Apple enables OpenMP later on, this code will also allow for parallelization to occur.
491
+
492
+
The reason for the lack of OpenMP support is because under OS X, you are not using the \texttt{gcc} compiler. Instead, all the requests are being redirected to \texttt{llvm}. As of LLVM 3.7, the \href{https://clang-omp.github.io/}{community initiative} to enable OpenMP has been merged into the \href{http://openmp.llvm.org/}{official branch}. Thus, there is hope in the next release of Xcode (around WWDC in June 2016) that OpenMP will work on OS X.
493
+
494
+
495
+
\subsubsection{Additional Information / Help}
496
+
497
+
Below are additional resources that provide information regarding compiling Rcpp code on OS X.
498
+
499
+
\begin{enumerate}
500
+
\item A helpful post was provided by Brian Ripley regarding the use of compiling R code with OS X in April 2014 \href{https://stat.ethz.ch/pipermail/r-sig-mac/2014-April/010835.html}{on the \code{r-sig-mac} list}, which is generally recommended for OS X-specific questions and further consultation.
501
+
\item Another helpful write-up for installation / compilation on OS X Mavericks is
449
502
provided \href{http://www.bioconductor.org/developers/how-to/mavericks-howto/}{by the BioConductor project}.
503
+
\item Lastly, another resource that exists for installation / compilation help is provided at \url{http://thecoatlessprofessor.com/programming/r-compiler-tools-for-rcpp-on-os-x/}.
504
+
\end{enumerate}
450
505
451
-
Also see \faq{q:OSXArma} below.
506
+
\textbf{Note:} If you are running into trouble compiling code with RcppArmadillo, please also see \faq{q:OSXArma} listed below.
452
507
453
508
%At the time of writing this paragraph (in the spring of 2011), \pkg{Rcpp}
454
509
%(just like CRAN) supports all OS X releases greater or equal to 10.5.
@@ -516,17 +571,34 @@ should be available.
516
571
\subsection{I am having problems building RcppArmadillo on OS X, any help ?}
517
572
\label{q:OSXArma}
518
573
519
-
Odds are your build failures are due to the absense of \texttt{gfortran}
520
-
and its associated libraries. Alternatively, you have them installed,
521
-
but \R simply doesn't know how to locate them.
574
+
Odds are your build failures are due to the absence of \texttt{gfortran}
575
+
and its associated libraries. The errors that you may receive are related to either:
576
+
\begin{center}
577
+
\textbf{``-lgfortran''} or \textbf{``-lquadmath''}
578
+
\end{center}
579
+
580
+
To rectify the root of these errors, there are two options available. The first option is to download and use a fixed set of \texttt{gfortran} binaries that are used to compile R for OS X (e.g. given by the maintainers of the OS X build). The second option is to either use pre-existing \texttt{gfortran} binaries on your machine or download the latest.
522
581
523
-
While \texttt{gfortran} is distributed as part of \texttt{gcc} and hence
524
-
is available by default on most Linux distributions, it is not
525
-
distributed as part of Apple's command line tools. So, unfortunately,
526
-
you're going to need to install \texttt{gfortran} and its associated
527
-
libraries yourself.
582
+
\subsubsection{Fixed set of \texttt{gfortran} binaries}
528
583
529
-
Most OS X users have opted into using a custom packaging solution;
584
+
Within this option, you will install a pre-compiled \code{gfortran} binary from
585
+
\href{http://r.research.att.com/libs/}{\texttt{r.research.att.com/libs/}}. The binary listed here was compiled by Simon Urbanek the maintainer of the OS X R versions.
586
+
587
+
To install the pre-compiled \code{gfortran} binary, do the following:
588
+
\begin{enumerate}
589
+
\item Open \texttt{Terminal} found in \texttt{/Applications/Utilities/}
For more information on this error, please see TheCoatlessProfessor's \href{http://thecoatlessprofessor.com/programming/rcpp-rcpparmadillo-and-os-x-mavericks-lgfortran-and-lquadmath-error/}{Rcpp, RcppArmadillo and OS X Mavericks "-lgfortran" and "-lquadmath" error}.
598
+
599
+
\subsubsection{Pre-existing or latest \texttt{gfortran} binaries}
600
+
601
+
Most OS X users that have a pre-existing \texttt{gfortran} binaries or want the latest version, typically use a custom packaging solution to install \texttt{gfortran};
0 commit comments