Skip to content

Commit 08ceaaf

Browse files
committed
some polish for James's nice Rcpp-FAQ addition
also added to ChangeLog and NEWS
1 parent 3e0e2ae commit 08ceaaf

File tree

3 files changed

+67
-19
lines changed

3 files changed

+67
-19
lines changed

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2016-02-06 James J Balamuta <[email protected]>
2+
3+
* vignettes/Rcpp-FAQ.Rnw (Rcpp): Additional material, and corrections,
4+
for use on OS X
5+
16
2016-01-30 Qiang Kou <[email protected]>
27

38
* inst/include/Rcpp/vector/Subsetter.h: Fix the error under gc

inst/NEWS.Rd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
\itemize{
2929
\item An entry was added to the Rcpp-FAQ vignette describing the required
3030
packages for vignette building (\ghit{422}).
31+
\item Use on OS X was further detailed (James Balamuta in \ghpr{433} with
32+
further review by Bob Rudis)
3133
}
3234
}
3335
}

vignettes/Rcpp-FAQ.Rnw

Lines changed: 60 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -433,74 +433,112 @@ complain to its vendor if you are still upset.
433433
\subsection{I am having problems building Rcpp on OS X, any help ?}
434434
\label{q:OSX}
435435

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.
436+
There are three known issues regarding Rcpp build problems on OS X. If you are
437+
building packages with RcppArmadillo, there is yet another issue that is
438+
addressed separately in \faq{q:OSXArma} below.
437439

438440
\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 $\le 10.8$) or \href{https://developer.apple.com/library/ios/technotes/tn2339/_index.html}{Xcode Command Line Tools} (OS X $\ge 10.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.
441+
By default, OS X does not ship with an active compiler. To enable a compiler one
442+
must either install
443+
\href{https://itunes.apple.com/us/app/xcode/id497799835?mt=12}{Xcode} (OS X
444+
$\le 10.8$) or
445+
\href{https://developer.apple.com/library/ios/technotes/tn2339/_index.html}{Xcode
446+
Command Line Tools} (OS X $\ge 10.9$). We will focus on the later as the
447+
installation requires the use of \texttt{Terminal} and the install size is
448+
significantly less than the prior, which is setup using an installer.
440449

441450
To install XCode Command Line Tools, one must do the following:
442451

443452
\begin{enumerate}
444453
\item Open \texttt{Terminal} found in \texttt{/Applications/Utilities/}
445454
\item Type the following:
446-
<<osx_xcode,engine='bash', eval = F>>=
455+
456+
<<lang=bash>>=
447457
$ xcode-select --install
448458
@
449459
\item Press "Install" on the window that pops up.
450460
\item After the installation is complete, type the following in \texttt{Terminal} to ensure the installation was successful:
451461

452-
<<osx_xcode_gcc,engine='bash', eval = F>>=
462+
<<lang=bash>>=
453463
$ gcc --version
454464
@
455465
\end{enumerate}
456466

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.
467+
After major system updates, e.g. going from version 10.11 to 10.12, you may need
468+
to accept the terms and licenses associated the the Xcode command line tools
469+
prior to being allowed to compile again.
458470

459471
To do so, open the \texttt{Terminal} found in \texttt{/Applications/Utilities/} and type:
460472

461-
<<osx_xcode_git,engine='bash', eval = F>>=
473+
<<lang=bash>>=
462474
$ git
463475
@
464476

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.
477+
Press spacebar to move down to the end of the file. There, you should see a
478+
prompt asking whether or not you accept the terms via either "Yes" or
479+
"No". Enter "Yes" if you agree to the terms to have the command line tools
480+
reactivated.
466481

467482
\subsubsection{Differing Mac OS X R Versions Leading to Binary Failures}
468483

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.
484+
There are currently two distinct versions of R for OS X. The first version is a
485+
legacy version meant for Mac OS X 10.6 (Snow Leopard) - 10.8 (Mountain
486+
Lion). The second version is for more recent system Mac OS X 10.9 (Mavericks),
487+
10.10 (Yosemite), 10.11 (El Capitan). The distinction comes as a result of a
488+
change in the compilers shipped with the operating system. As a result, avoid
489+
sending package binaries if it is known that your collaborators are working on
490+
older systems as the R binaries for these two versions will not be able to mix.
470491

471492
\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:
493+
The OS X operating environment lacks the ability to parallelize sections of code
494+
using the \href{http://openmp.org/wp/}{OpenMP} standard. As a result, make sure
495+
to protect any reference to OpenMP. In this case, protect the inclusion of
496+
headers with:
473497

474-
<<osx_openmp_header, engine="Rcpp", eval = F>>=
498+
<<lang=cpp>>=
475499
#ifdef _OPENMP
476500
#include <omp.h>
477501
#endif
478502
@
479503

480504
And when one goes to parallelize portions of code use:
481505

482-
<<osx_openmp_code, engine="Rcpp", eval = F>>=
506+
<<lang=cpp>>=
483507
#ifdef _OPENMP
484508
// multithreaded OpenMP version of code
485509
#else
486510
// single-threaded version of code
487511
#endif
488512
@
489513

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.
514+
Doing so will enable the parallelization of the process on Linux and Windows. In
515+
the event that Apple enables OpenMP later on, this code will also allow for
516+
parallelization to occur.
491517

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.
518+
The reason for the lack of OpenMP support is because under OS X, you are not
519+
using the \texttt{gcc} compiler. Instead, all the requests are being redirected
520+
to \texttt{llvm}. As of LLVM 3.7, the
521+
\href{https://clang-omp.github.io/}{community initiative} to enable OpenMP has
522+
been merged into the \href{http://openmp.llvm.org/}{official branch}. Thus,
523+
there is hope in the next release of Xcode (around WWDC in June 2016) that
524+
OpenMP will work on OS X.
493525

494526

495527
\subsubsection{Additional Information / Help}
496528

497529
Below are additional resources that provide information regarding compiling Rcpp code on OS X.
498530

499531
\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
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/}.
532+
\item A helpful post was provided by Brian Ripley regarding the use of
533+
compiling R code with OS X in April 2014
534+
\href{https://stat.ethz.ch/pipermail/r-sig-mac/2014-April/010835.html}{on
535+
the \code{r-sig-mac} list}, which is generally recommended for OS
536+
X-specific questions and further consultation.
537+
\item Another helpful write-up for installation / compilation on OS X Mavericks is provided
538+
\href{http://www.bioconductor.org/developers/how-to/mavericks-howto/}{by the BioConductor project}.
539+
\item Lastly, another resource that exists for installation / compilation
540+
help is provided at
541+
\url{http://thecoatlessprofessor.com/programming/r-compiler-tools-for-rcpp-on-os-x/}.
504542
\end{enumerate}
505543

506544
\textbf{Note:} If you are running into trouble compiling code with RcppArmadillo, please also see \faq{q:OSXArma} listed below.
@@ -588,10 +626,12 @@ To install the pre-compiled \code{gfortran} binary, do the following:
588626
\begin{enumerate}
589627
\item Open \texttt{Terminal} found in \texttt{/Applications/Utilities/}
590628
\item Type the following:
591-
<<osx_gfortran, engine='bash', eval = F>>=
629+
630+
<<lang=bash>>=
592631
curl -O http://r.research.att.com/libs/gfortran-4.8.2-darwin13.tar.bz2
593632
sudo tar fvxz gfortran-4.8.2-darwin13.tar.bz2 -C /
594633
@
634+
595635
\end{enumerate}
596636

597637
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}.
@@ -634,7 +674,8 @@ of paths suitable to be passed to \code{FLIBS}. \R will then search
634674
these paths when attempting to locate e.g \code{libgfortran} when
635675
compiling \pkg{RcppArmadillo} or other FORTRAN-dependent code.
636676

637-
Also see \faq{q:OSX} above, and the links provided in that answer. In the event the above solution does not satisfy all the OS X build problems.
677+
Also see \faq{q:OSX} above, and the links provided in that answer. In the event
678+
the above solution does not satisfy all the OS X build problems.
638679

639680
\section{Examples}
640681

0 commit comments

Comments
 (0)