Rob, What you should do, is _always_ inherit the compiler which was used to build R. That is the 'Right' way to go and it is what will happen per default if you are using Makevars to compile you package. If you need to use configure, there are hints in R-exts and we can help more specifically, preferably you have a package somewhere. This way you do not run into (weird) problems which can arise when you use different compilers for R and your package.
The issue you are seeing right now on the Mac is that some users will not be able to compile packages from source using their system. For most users, if you distribute your package via CRAN / Bioconductor they will have the option of receiving a binary version of the package and therefore do not need a C++ compiler. In addition, even if you want them to install from source, using a configure script will (most likely) not really help at all - if they don't have the Xcode supplied compiler, they are extremely unlikely to have any other compiler installed on their system. And really, if a user is using the CRAN binary of R and wants to install a package from source, it is really their responsibility to setup their system to do so. In summary, I don't think you will help anyone with a configure step trying to locate an alternative compiler. Finally, you can get the Xcode compiler by starting up Xcode, go to preferences -> Downloads and then click on "install command line tools". It is irritating you have to do this, but that is the situation. Best, Kasper On Tue, Oct 8, 2013 at 3:00 PM, Robert Bruggner <[email protected]> wrote: > Hi all, > > I'm developing a package that needs to be compiled on installation but am > unsure how to ensure that the proper C++ compiler is invoked when > installing this package from source. Is there anyway to, at build time, > auto-detect and set the available compiler using configure / Makevars? > > More specifically, I'm using the CRAN-provided binary of R 3.02 running > on Mac OS 10.8.5 with XCode 5 installed. By default, the Makeconf included > with the R installation ($RHOME/Resources/Makeconf) has CXX set as: > > CXX = llvm-g++-4.2 -arch x86_64 > > However, as llvm-g++-4.2 is no longer distributed with XCode5, package > installation fails when I attempt to install from source with an expected > "llvm-g++-4.2: command not found" message. > > I see that one solution is to manually set CXX in the ~/.R/Makevars file. > However, I'm wondering if it's possible to have the combination of a > configure script / Makevars.in automatically detect and set the CXX > variable upon installation. > > As I have it specified currently, my configure.ac script use the > AC_PROG_CXX macro to detect and set CXX. > https://github.com/nolanlab/Rclusterpp/blob/dev/configure.ac > > Then, in my Makevars.in, I attempt to specify the value of CXX detected by > the configure script > https://github.com/nolanlab/Rclusterpp/blob/dev/src/Makevars.in > > I can then run the configure script manually and, in the produced Makevars > file, it appears to detect and set CXX to the proper complier, i.e.: > > CXX=g++ -arch x86_64 > > However, when I then try and install the package, it seems to default back > to the using llvm-g++-4.2 as the compiler and thus, installation fails. > > I of course could be approaching this in completely the wrong way. Any > suggestions on how I might be able to auto-detect and set the appropriate > compiler at build time? > > -Rob > > _______________________________________________ > R-SIG-Mac mailing list > [email protected] > https://stat.ethz.ch/mailman/listinfo/r-sig-mac > [[alternative HTML version deleted]] _______________________________________________ R-SIG-Mac mailing list [email protected] https://stat.ethz.ch/mailman/listinfo/r-sig-mac
