Hi all, I have a C function, say Cfun, that calls Lapack's DGEMM routine and I need to create a shared library to use Cfun inside R. The C file is the following #include<stdio.h> #include<R.h> #include<R_ext/Lapack.h> void Cfun(double *res, double *X, int *n, int *q) { char *ptr_TRANSA, TRANSA='T', *ptr_TRANSB, TRANSB='N'; ptr_TRANSA=&TRANSA; ptr_TRANSB=&TRANSB; double *ptr_ALPHA, ALPHA=1.0, *ptr_BETA, BETA=0.0; ptr_ALPHA=&ALPHA; ptr_BETA=&BETA; dgemm_(ptr_TRANSA, ptr_TRANSB, q, q, n, ptr_ALPHA, X, n, X, n, ptr_BETA, res, q); } In Ubuntu I have no problem in compiling: R CMD SHLIB -llapack myfile.c. However, under Windows the -llapack flag is not recognised and I am able to get the code compiled only if I build an R package with the suitable Makevars file options: PKG_LIBS=$(LAPACK_LIBS) $(FLIBS). Is there a way to get the .dll without resorting to build a package? Thanks in advance, N. Lunardon -- View this message in context: http://r.789695.n4.nabble.com/Problem-with-shared-library-and-lapack-under-windows-tp4708092.html Sent from the R devel mailing list archive at Nabble.com.
Berend Hasselman
2015-Jun-03 09:03 UTC
[Rd] Problem with shared library and lapack under windows
> On 03-06-2015, at 09:48, bstr <nicola.lunardon at hotmail.it> wrote: > > Hi all, > > I have a C function, say Cfun, that calls Lapack's DGEMM routine and I need > to create a shared library to use Cfun inside R. The C file is the following > > #include<stdio.h> > #include<R.h> > #include<R_ext/Lapack.h> > > > void Cfun(double *res, double *X, int *n, int *q) > { > char *ptr_TRANSA, TRANSA='T', *ptr_TRANSB, TRANSB='N'; > ptr_TRANSA=&TRANSA; > ptr_TRANSB=&TRANSB; > double *ptr_ALPHA, ALPHA=1.0, *ptr_BETA, BETA=0.0; > ptr_ALPHA=&ALPHA; > ptr_BETA=&BETA; > > dgemm_(ptr_TRANSA, ptr_TRANSB, q, q, n, ptr_ALPHA, X, n, X, n, ptr_BETA, > res, q); > } > > In Ubuntu I have no problem in compiling: R CMD SHLIB -llapack myfile.c. > However, under Windows the -llapack flag is not recognised and I am able to > get the code compiled only if I build an R package with the suitable > Makevars file options: PKG_LIBS=$(LAPACK_LIBS) $(FLIBS). Is there a way to > get the .dll without resorting to build a package? >I wouldn?t exactly know since I?m not using Windows. Try this: R CMD config LAPACK_LIBS to see the command line options needed. And why are you using dgemm_? Use the F77_CALL macro provided by R; you?ll be less system dependent that way. Berend
Prof Brian Ripley
2015-Jun-04 17:33 UTC
[Rd] Problem with shared library and lapack under windows
On 03/06/2015 08:48, bstr wrote:> Hi all, > > I have a C function, say Cfun, that calls Lapack's DGEMM routine and I need > to create a shared library to use Cfun inside R. The C file is the following > > #include<stdio.h> > #include<R.h> > #include<R_ext/Lapack.h> > > > void Cfun(double *res, double *X, int *n, int *q) > { > char *ptr_TRANSA, TRANSA='T', *ptr_TRANSB, TRANSB='N'; > ptr_TRANSA=&TRANSA; > ptr_TRANSB=&TRANSB; > double *ptr_ALPHA, ALPHA=1.0, *ptr_BETA, BETA=0.0; > ptr_ALPHA=&ALPHA; > ptr_BETA=&BETA; > > dgemm_(ptr_TRANSA, ptr_TRANSB, q, q, n, ptr_ALPHA, X, n, X, n, ptr_BETA, > res, q); > } > > In Ubuntu I have no problem in compiling: R CMD SHLIB -llapack myfile.c. > However, under Windows the -llapack flag is not recognised and I am able to > get the code compiled only if I build an R package with the suitable > Makevars file options: PKG_LIBS=$(LAPACK_LIBS) $(FLIBS). Is there a way to > get the .dll without resorting to build a package?SHLIB reads a Makevars file .... The manual says so right at the top of the section http://cran.r-project.org/doc/manuals/r-release/R-exts.html#Using-Makevars .> > Thanks in advance, > > N. Lunardon-- Brian D. Ripley, ripley at stats.ox.ac.uk Emeritus Professor of Applied Statistics, University of Oxford 1 South Parks Road, Oxford OX1 3TG, UK