[R-SIG-Mac] cblas on Mac and Linux

Prof Brian Ripley ripley at stats.ox.ac.uk
Fri Mar 20 08:48:28 CET 2009


On Fri, 20 Mar 2009, Gad Abraham wrote:

> Hi,
>
> I've got a package with some C code calling cblas functions (e.g., 
> cblas_dgemm). The code is called using .C() . In order to compile correctly 
> either cblas.h on Linux or Accelerate.h on a Mac:
>
> #include <R.h>
> #ifdef MACOSX
> #include <Accelerate/Accelerate.h>
> #else
> #include <cblas.h>
> #endif
>
> Of course, this doesn't work well with the standard Makevars 
> PKG_LIBS=$(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) since I need to set the 
> -DMACOSX flag for each platform.
>
> Do I need to create another makefile to decide which OS the code is running 
> on, or is there an easier way of doing this?

You use configure -- see 'Wrtiing R Extensions' --  to fill in a 
Makevars.in.  But beware that in general $(BLAS_LIBS does not contain 
a cblas, even on MacOS X, so if portability is any sort of issue, you 
need to set PKG_LIBS via configure too.

>
> Thanks,
> Gad
>
> -- 
> Gad Abraham
> MEng Student, Dept. CSSE and NICTA
> The University of Melbourne
> Parkville 3010, Victoria, Australia
> email: gabraham at csse.unimelb.edu.au
> web: http://www.csse.unimelb.edu.au/~gabraham
>
> _______________________________________________
> R-SIG-Mac mailing list
> R-SIG-Mac at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-mac
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-SIG-Mac mailing list