[Rd] getNativeSymbolInfo fails with Fortran symbol.
In the following code routine 'initaquaphy' is defined in Fortran, and dynamically loaded into R.: test.f: subroutine initaquaphy(odeparms) external odeparms double precision pars(19) common /myparms/pars call odeparms(19, pars) return end $ R CMD SHLIB Aquaphy.f gfortran -fpic -g -O2 -c test.f -o test.o gcc -std=gnu99 -shared -L/usr/local/lib -o test.so test.o -lgfortran -lm and linked into the package dll (or so). Help for is.loaded() and getNativeSymbolInfo() say not to use symbol.For() to convert to Fortran-specific symbols. However, on Linux, getNativeSymbolInfo is unable to find 'initaquaphy' in 'test.so', but does find 'initaquaphy_'. Note that is.loaded() works as advertised. Furthermore, this code works in Windows, R-2.6.2patched44759. triggerbug.R: system("R CMD SHLIB test.f") dyn.load(paste("test",.Platform$dynlib.ext,sep="")) is.loaded("initaquaphy", PACKAGE="test") getNativeSymbolInfo("initaquaphy_", PACKAGE="test") getNativeSymbolInfo("initaquaphy", PACKAGE="test") cat("All Done") Resulting in: > source("triggerbug.R", echo=TRUE, print.eval=TRUE) > system("R CMD SHLIB test.f") gfortran -fpic -g -O2 -c test.f -o test.o gcc -std=gnu99 -shared -L/usr/local/lib -o test.so test.o -lgfortran -lm > dyn.load(paste("test",.Platform$dynlib.ext,sep="")) > is.loaded("initaquaphy", PACKAGE="test") [1] TRUE > getNativeSymbolInfo("initaquaphy_", PACKAGE="test") $name [1] "initaquaphy_" $address attr(,"class") [1] "NativeSymbol" $package DLL name: test Filename: /home/setzer/tasks/Programming_Projects/test.so Dynamic lookup: TRUE attr(,"class") [1] "NativeSymbolInfo" > getNativeSymbolInfo("initaquaphy", PACKAGE="test") Error in FUN("initaquaphy"[[1L]], ...) : no such symbol initaquaphy in package test > Have I misunderstood the help page, or is this a bug? --please do not edit the information below-- Version: platform = i686-pc-linux-gnu arch = i686 os = linux-gnu system = i686, linux-gnu status = beta major = 2 minor = 7.0 year = 2008 month = 04 day = 07 svn rev = 45159 language = R version.string = R version 2.7.0 beta (2008-04-07 r45159) Locale: LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C Search Path: .GlobalEnv, package:deSolve, package:stats, package:graphics, package:grDevices, package:utils, package:datasets, package:methods, Autoloads, package:base R. Woodrow Setzer, Ph. D. National Center for Computational Toxicology http://www.epa.gov/comptox US Environmental Protection Agency Mail Drop B205-01/US EPA/RTP, NC 27711 Ph: (919) 541-0128Fax: (919) 541-1194 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] odesolve dynload example
I'm the maintainer of odesolve. In the ...odesolve/dynload/c directory of the windows distribution are two files that should not be: mymod.o and mymod.so (I just noticed them). Try deleting them and rerunning your compilation. By the way, you might want to take a look at deSolve, which supercedes odesolve. deSolve includes lsoda with the same API as in odesolve, but also includes several other ode solvers you might find useful. In the next several months, odesolve will be deprecated. R. Woodrow Setzer, Ph. D. National Center for Computational Toxicology http://www.epa.gov/comptox US Environmental Protection Agency Mail Drop B205-01/US EPA/RTP, NC 27711 Ph: (919) 541-0128Fax: (919) 541-1194 Peter Dalgaard <[EMAIL PROTECTED] tat.ku.dk> To Sent by: "Redding, Matthew" r-devel-bounces@ <[EMAIL PROTECTED]> r-project.org cc r-devel@r-project.org Subject 09/16/2008 01:59 Re: [Rd] odesolve dynload example AM Redding, Matthew wrote: > Hello R Developers, > > This is my first foray into using c-code with R, so please forgive my > foolishness. > I had a look at the archives and did not find anything on this, so > hopefully I am not doubling up. > > I have tried to use R cmd to create an object file from the odesolve > dynload example. > I am using windows and have just installed rtools, and have the latest > version of stable R (2..7.2). > > This is what happened: > > C:\Program Files\R\R-2.7.2\library\odesolve\dynload\c>Rcmd SHLIB mymod.c > making mymod.d from mymod.c > windres --preprocessor="gcc -E -xc -DRC_INVOKED" -I > C:/PROGRA~1/R/R-27~1.2/include -i mymod_res.rc -o mymod_res.o > gcc -std=gnu99 -shared -s -o mymod.dll mymod.def mymod.o mymod_res.o > -LC:/PROGRA~1/R/R-27~1.2/bin-lR > Cannot export myderivs: symbol not found > Cannot export myjac: symbol not found > Cannot export mymod: symbol not found > mymod.o: In function `mymod': > /home/setzer/tasks/Programming_Projects/odesolve/odesolve/inst/dynload/c > /mymod.c:14: undefined reference to `GLOBAL_OFFSET_TA > BLE_' > mymod.o: In function `myderivs': > /home/setzer/tasks/Programming_Projects/odesolve/odesolve/inst/dynload/c > /mymod.c:21: undefined reference to `GLOBAL_OFFSET_TA > BLE_' > mymod.o: In function `myjac': > /home/setzer/tasks/Programming_Projects/odesolve/odesolve/inst/dynload/c > /mymod.c:30: undefined reference to `GLOBAL_OFFSET_TA > BLE_' > collect2: ld returned 1 exit status > make: *** [mymod.dll] Error 1 > > Any ideas what I have not got set up properly? What do I need to do to > get this firing? > Advice appreciated. > I'm a bit rusty on the windows tools, but it looks like mymod.o and mymod_res.rc not being made above. Any chance that you have old versions lying around? -- O__ Peter Dalgaard Ă˜ster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Getting 'LinkingTo' to find the right library
I am experimenting with exporting pointers to some of the functions in deSolve so that other packages may import them, using the 'R_RegisterCCallable' mechanism. I have added a header file and some other C code in inst/include of the deSolve source package that need to be accessible to other packages. I have a site-library set up in Rprofile.site where all installed packages go, and as long as my experimental version of deSolve is installed there, I'd like to install my modified copy of deSolve in a test library. However, when I try to install my test package (which includes both Depends: deSolve and LinkingTo: deSolve, in its Description file, as described in 'R Extensions'), compilation fails, because the appropriate C code cannot be found (there is also an unrelated problem in deSolve_stubs.c triggering the "unexpected ')' before '*' token" error). [test]$ R CMD INSTALL -l C:/home/Rlib-test dma -- Making package dma adding build stamp to DESCRIPTION installing NAMESPACE file and metadata making DLL ... gcc -std=gnu99 -Ic:/PROGRA~1/R/R-28~1.1PA/include -I"C:/PROGRA~1/R/site-librar y/deSolve/include"-O3 -Wall -c R_init_dma.c -o R_init_dma.o R_init_dma.c:1:27: error: deSolve_stubs.c: No such file or directory R_init_dma.c:3: error: expected ')' before '*' token make[3]: *** [R_init_dma.o] Error 1 make[2]: *** [srcDynlib] Error 2 make[1]: *** [all] Error 2 make: *** [pkg-dma] Error 2 *** Installation of dma failed *** Removing 'C:/home/Rlib-test/dma' It seems that although the 'site-library/deSolve/include' folder is included in the search list for included files, the 'Rlib-test/deSolve/include' folder is not. The folder that includes both the experimental version of deSolve and the test package dma also contains a .Rprofile file which places 'C:/home/Rlib-test' at the front of the library search path, and I have confirmed that this is so (in fact, the above INSTALL command does not need the '-l ' argument; the default install location is Rlib-test for installs from this folder). It looks as if the code in INSTALL that sets up the -I arguments to gcc does not find the library path defined for this folder. Can someone point me to the right way to do this? System information: Version: platform = i386-pc-mingw32 arch = i386 os = mingw32 system = i386, mingw32 status = Patched major = 2 minor = 8.1 year = 2009 month = 01 day = 04 svn rev = 47474 language = R version.string = R version 2.8.1 Patched (2009-01-04 r47474) Windows XP (build 2600) Service Pack 2 Locale: LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252 Search Path: .GlobalEnv, package:stats, package:graphics, package:grDevices, package:utils, package:datasets, package:methods, Autoloads, package:base R. Woodrow Setzer, Ph. D. National Center for Computational Toxicology http://www.epa.gov/comptox US Environmental Protection Agency Mail Drop B205-01/US EPA/RTP, NC 27711 Ph: (919) 541-0128Fax: (919) 541-1194 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Getting 'LinkingTo' to find the right library
(I just realized that when "they" upgraded my mail program, "they" reset my preferences to send html and text for internet mail. I have fixed the preferences to text only, and apologize). Well, where would I get the idea it was NOT reading .Rprofile, since it clearly IS reading Rprofile.site? However, I mainly thought that the library being installed to would be used to find the dependent package, because of this bug fix entry for version 2.7.2: o The use of multiple packages in 'LinkingTo' works again, and now works when the dependent packages are in the library to be installed to (but not in the library path seen by R --vanilla). Also, in this paragraph from the INSTALL help item: To install into the library tree 'lib', use 'R CMD INSTALL -l lib pkgs'. This prepends 'lib' to 'R_LIBS' for duration of the install, so required packages in the installation directory will be found (and used in preference to those in other libraries). Setting R_LIBS works (I DID try this before, but must have fumbled something). R. Woodrow Setzer, Ph. D. National Center for Computational Toxicology http://www.epa.gov/comptox US Environmental Protection Agency Mail Drop B205-01/US EPA/RTP, NC 27711 Ph: (919) 541-0128Fax: (919) 541-1194). Prof Brian Ripley wrote on 02/02/2009 04:22:52 PM: > [image removed] > > Re: [Rd] Getting 'LinkingTo' to find the right library > > Prof Brian Ripley > > to: > > Woodrow Setzer > > 02/02/2009 04:22 PM > > Cc: > > r-devel > > Where did you get the idea that R CMD INSTALL is reading .Rprofile? > (AFAIR it does so only to find the installation library, as R CMD > INSTALL --help says it will.) > > You need to set R_LIBS in the environment to get the library path you > want. This is not specific to 'LinkingTo'. > > On Mon, 2 Feb 2009, setzer.wood...@epamail.epa.gov wrote: > > > > > I am experimenting with exporting pointers to some of the functions in > > deSolve so that other packages may import them, using the > > 'R_RegisterCCallable' mechanism. I have added a header file and some > > other C code in inst/include of the deSolve source package that need to > > be accessible to other packages. I have a site-library set up in > > Rprofile.site where all installed packages go, and as long as my > > experimental version of deSolve is installed there, I'd like to install > > my modified copy of deSolve in a test library. However, when I try to > > install my test package (which includes both Depends: deSolve and > > LinkingTo: deSolve, in its Description file, as described in 'R > > Extensions'), compilation fails, because the appropriate C code cannot > > be found (there is also an unrelated problem in deSolve_stubs.c > > triggering the "unexpected ')' before '*' token" error). > > > > [test]$ R CMD INSTALL -l C:/home/Rlib-test dma > > > > > > -- Making package dma > > adding build stamp to DESCRIPTION > > installing NAMESPACE file and metadata > > making DLL ... > > gcc -std=gnu99 -Ic:/PROGRA~1/R/R-28~1.1PA/include > > -I"C:/PROGRA~1/R/site-librar > > y/deSolve/include"-O3 -Wall -c R_init_dma.c -o R_init_dma.o > > R_init_dma.c:1:27: error: deSolve_stubs.c: No such file or directory > > R_init_dma.c:3: error: expected ')' before '*' token > > make[3]: *** [R_init_dma.o] Error 1 > > make[2]: *** [srcDynlib] Error 2 > > make[1]: *** [all] Error 2 > > make: *** [pkg-dma] Error 2 > > *** Installation of dma failed *** > > > > Removing 'C:/home/Rlib-test/dma' > > > > It seems that although the 'site-library/deSolve/include' folder is > > included in the search list for included files, the > > 'Rlib-test/deSolve/include' folder is not. The folder that includes > > both the experimental version of deSolve and the test package dma also > > contains a .Rprofile file which places 'C:/home/Rlib-test' at the front > > of the library search path, and I have confirmed that this is so (in > > fact, the above INSTALL command does not need the '-l ' argument; the > > default install location is Rlib-test for installs from this folder). > > It looks as if the code in INSTALL that sets up the -I arguments to gcc > > does not find the library path defined for this folder. Can someone > > point me to the right way to do this? > > > > System information: > > Version: > > platform = i386-pc-mingw32 > > arch = i386 > > os = mingw32 > > system = i386, mingw32 > > status = Patched > > major = 2 > > minor = 8.1 > > year = 2009 > > month = 01 > > day = 04 > > svn rev = 47474 > > language = R > > version.string = R version 2.8.1 Patched (2009-01-04 r47474) > > > > Windows XP (build 2600) Service Pack 2 > > > > Locale: > > LC_COLLATE=English_United States.1252;LC_CTYPE=English_United > > States.1252;LC_MONETARY=English_United > > States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252 > > > > Search Path: > > .GlobalEnv, package:stats, package:graphics, package:grDevices, > > package:utils, package:datasets, package:methods, Autoloa