Many thanks to Brian for his very useful information and help. A quick look at mgcv package already gives me some directions to try. I remember that I tried to use Rlapack.dll instead of R.dll without success, perhaps because I don't know how to build an import library for Rlapack.dll and link against it (README.packages shows how to do this for R.dll using R.exp, but I could not find Rlapack.exp). I will try to see if I can figure out this part using VC++6.0.





Yes, I am still using R-2.2.1. I did try to upgrade it to R-2.4.1. However, the newer versions cause some troubles for my C programs. They produce error messages when my DLL are loaded into R. The problem relates to function calls such as isfinite. I haven't figured out why my C programs have this problem with newer versions of R but not with version 2.2.1. I remember there was a post on this issue in this list, but I did not see any solution. I hope to find a clue about it too so that I can keep the pace of R development.





Paul.








----- Original Message -----


From: Prof Brian Ripley <ripley@stats.ox.ac.uk>


Date: Friday, March 30, 2007 1:56 am


Subject: Re: [R] Using functions in LAPACK in a C program


To: Paul August <paulaugust2003@yahoo.com>


Cc: r-help@stat.math.ethz.ch





> On Thu, 29 Mar 2007, Paul August wrote:


> 


> > Hi,


> >


> > I wonder where I can find an example of using a function in 


> LAPACK 


> > library in a user's own C code.


> 


> In about 20 R packages, e.g. the recommended package mgcv.


> 


> > I wrote a C program which will be 


> > compiled and linked to produce a DLL file and then loaded into 


> R. I hope 


> > to use a function from LAPACK library, for example, dgesdd, in 


> the 


> > program. Following R manual, I call the function by 


> F77_CALL(dgesdd) in 


> > the program. The program can be compiled without problems. 


> However, when 


> > it is linked to produce a DLL file, I get an error message


> >


> >  Test.obj : error LNK2001: unresolved external symbol _dgesdd_


> >  Test.dll : fatal error LNK1120: 1 unresolved externals


> >


> > I use VC++6.0 and the command of linking is something like this


> >


> >  link.exe Rdll.lib /nologo /dll /out:Test.dll 


> /libpath:C:\R\R-2.2.1\src\gnuwin32 Test.obj


> >


> > Apparently, the linker cannot resolve dgesdd from Rdll.lib. If 


> anyone 


> > knows what I missed here or any example that shows how this 


> can be done 


> > properly, please let me know. Thanks a lot.


> 


> It is in Rlapack.dll not R.dll.


> 


> The linking information is in 'Writing R Extensions' for those 


> using the 


> recommended compilation system (search for LAPACK_LIBS).


> 


> You will need to build an import library for Rlapack.dll and 


> link against 


> that.


> 


> And BTW you seem to be using R 2.2.1: please update as we can 


> only offer 


> accurate advice on recent systems.


> 


> -- 


> Brian D. 


> Ripley,                  ripley@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


> 


> ______________________________________________


> R-help@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


> and provide commented, minimal, self-contained, reproducible code.


> 

-----------------------------------------------
Dr. Paul Y. Peng
Associate Professor of Biostatistics
Department of Community Health and Epidemiology
   and Department of Mathematics and Statistics
Queen's University, Kingston, ON, K7L 3N6

Phone: 613-533-6000 Ext 78525
Email: pengp@queensu.ca
Fax: 613-533-6794
-----------------------------------------------

	[[alternative HTML version deleted]]

