I am trying to load C routines into R on windows, going through the the book S programming and the R manual, but I know I am missing some steps. I created a win32 DLL project in Visual C++ (ver. 6.0). It consists of one simple routine named test which accepts one *integer argument and one *double argument and performs a trivial computation. The dll is named test.dll. In R1022 for Windows, I run >dyn.load("d:/programs/library/test/test.dll") >testr_function(a,x) .C"d:/programs/library/test/test",as.integer(a),as.double(x)) These are both accepted, and I can use dyn.unload as well with test.dll. I notice that while loaded, Visual C++ cannot recompile test.dll. But when I try >testr(10,x) I get the message ?Error in .C("test", as.integer(a),as.double(x)) : C/Fortran function name not in load table?. I know I need a link step, or an install step, but I am missing something in the instructions. Perhaps just a quick piece of advice could get me to the next stage Richard Condit Smithsonian Tropical Research Institute -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Richard Condit <rick at eno.princeton.edu> writes:> I am trying to load C routines into R on windows, going through the the > book S programming and the R manual, but I know I am missing some steps. > > I created a win32 DLL project in Visual C++ (ver. 6.0). It consists of one > simple routine named test which accepts one *integer argument and one > *double argument and performs a trivial computation. The dll is named > test.dll. > > In R1022 for Windows, I run > > >dyn.load("d:/programs/library/test/test.dll") > >testr_function(a,x) > .C"d:/programs/library/test/test",as.integer(a),as.double(x)) > > These are both accepted, and I can use dyn.unload as well with test.dll. I > notice that while loaded, Visual C++ cannot recompile test.dll. > > But when I try > > >testr(10,x) > > I get the message ?Error in .C("test", as.integer(a),as.double(x)) : > C/Fortran function name not in load table?. > > I know I need a link step, or an install step, but I am missing something > in the instructions. Perhaps just a quick piece of advice could get me to > the next stageCompiling DLLs on Windows is tricky business, especially if you want to mix and match compilers. Detailed instructions for doing it is contained in the rw-faq file and readme.packages. There's a strong recommendation to use the toolkit based on the Mingw32 compiler and GNU utilities, but Visual C++ should be doable and there's a full example in readme.packages. -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Sun, 10 Jun 2001, Richard Condit wrote:> I am trying to load C routines into R on windows, going through the the > book S programming and the R manual, but I know I am missing some steps. > > I created a win32 DLL project in Visual C++ (ver. 6.0). It consists of one > simple routine named test which accepts one *integer argument and one > *double argument and performs a trivial computation. The dll is named > test.dll. > > In R1022 for Windows, I run > > >dyn.load("d:/programs/library/test/test.dll") > >testr_function(a,x) > .C"d:/programs/library/test/test",as.integer(a),as.double(x)) > > These are both accepted, and I can use dyn.unload as well with test.dll. I > notice that while loaded, Visual C++ cannot recompile test.dll.Yes, that's a feature of Windows (and some other OSes).> But when I try > > >testr(10,x) > > I get the message “Error in .C("test", as.integer(a),as.double(x)) : > C/Fortran function name not in load table”. > > I know I need a link step, or an install step, but I am missing something > in the instructions. Perhaps just a quick piece of advice could get me to > the next stage…Your .C call should be something like .C("test", as.integer(a), as.double(x)) and "test" must be exported by your DLL. Note: by default nothing is exported in Visual C++: you need a .def file in the project. I think you've missed the advice in readme.packages (in rw1023sp.zip), which has a section `Using Visual C++'. Despite the presence of that, using the recommended compiler is easier.... -- 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 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._