Yes, lots of packages link to Rblas. The help page for SHLIB tells you
Please consult section 'Creating shared objects' in the manual
'Writing R Extensions' for how to customize it (for example to add
'cpp' flags and to add libraries to the link step) and for details
of some of its quirks.
so it should not have been at all hard to find the information.
A portable way would be to have a file Makevars containing
PKG_LIBS=$(BLAS_LIBS)
Note that your precise example will not work in R-2.3.0 when it is
released, whereas the portable form will. (In fact it only works in
R-2.2.0 if you have previously make libRblas.a.)
On Thu, 9 Mar 2006, Rau, Roland wrote:
> Dear all,
>
> when making a DLL via Rcmd SHLIB is there a way to link against a
> library such as Rblas (I am on a Windows platform) on a case to case
> basis?
>
> I played a bit around with some self-written C-code which should call
> the function 'dasum' defined in Blas.h.
> I encountered the following problem:
>
> u:\codeplay>Rcmd SHLIB mysumming.c
> Rcmd SHLIB mysumming.c
> gcc --shared -s -o mysumming.dll mysumming.def mysumming.a
> -LU:/R/R-2.2.0/src/gnuwin32 -lg2c -lR
> mysumming.a(mysumming.o)(.text+0x1b):mysumming.c: undefined reference to
> `dasum_'
> collect2: ld returned 1 exit status
> make: *** [mysumming.dll] Error 1
>
> My (very limited) knowledge on C tells me that the function 'dasum'
> is actually defined (due to #include <R_ext/BLAS.h> in my C-file) but
> it needs to be linked against the correct library during the linking
> procedure. I guess the correct library should be Rblas.dll since I
> could do it "by hand" calling gcc like this:
>
> gcc --shared -s -o mysumming.dll mysumming.def mysumming.a
> -LU:/R/R-2.2.0/src/gnuwin32 -lg2c -lR -lRblas
>
> and it worked.
>
> Thank you very much for your help in advance.
> If you need more details such as the C-Code, the R-Code calling C, ..:
> just let me know.
>
> Thanks,
> Roland
>
>> version
> _
> platform i386-pc-mingw32
> arch i386
> os mingw32
> system i386, mingw32
> status
> major 2
> minor 2.0
> year 2005
> month 10
> day 06
> svn rev 35749
> language R
>
> u:\codeplay>gcc --version
> gcc --version
> gcc (GCC) 3.4.2 (mingw-special)
> Copyright (C) 2004 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions. There is
> NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
> PURPOSE.
>
> +++++
> This mail has been sent through the MPI for Demographic Rese...{{dropped}}
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html
>
--
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