Andéol Evain
2018-Jul-12 15:15 UTC
[Rd] R API for C/C++ initialisation issue appears with update to R.3.5
Hello everyone, I have a C++ program that calls R using R_tryEval, very similarly to what package RInside does. It used to work with R.3.4.3 and R.3.4.4. However, since I updated it to R.3.5.1, R sends an error message: "*Error in < My command > : the base graphics system is not registered*" for any command related to the graphics package. I made a ticket on stackoverflow about it: https://stackoverflow.com/ questions/51242993/difference-between-r-3-4-4-and-r-3-5-1-in-r-api-for-c But nobody could explain why so far. And after reducing my code further, I am now enclined to think this is actually a bug. The code provided in stackOverflow is already reduced, but not minimal yet. Since then, I reduced it further to really ensure that it was not an interference from anything around it. So I removed the GUI and the callbacks. Here is a really minimal example attached. In its current form, the program just sends the command : par("mar") to R, and then the command dev.off() . With R.3.4.4, this program print as output what is expected. No error occured during evaluation of the command : *No error occured during eval of "par(\"mar\")"EXAMPLE #1 Output: EXAMPLE #1 Output: Result is: "5.1"Result is: "5.1"Result is: "5.1"Result is: "5.1"No error occured during eval of "dev.off()"Result is: "1"* But the exact same program with R.3.5.1 gives: *An error occured during eval of "par(\"mar\")"No error occured during eval of "dev.off()"Result is: "1"* The error that occured is not displayed here, since I removed the callbacks to fetch it, but it was: *Error in par("mar") : the base graphics system is not registered* I compiled Microsoft Visual C++ Compiler 15.0 (amd64), and uses 64bits version of R. But previously I also observed the same behovior with 32bits. I also tried re-installing R from scratch, without effect. I am using Windows 10, 64bits Registry variables PATH and R_HOME are correctly set and points to the appropriate version of R, installed in the default directory. I'd be glad to hear any ideas about potential fixes or workaround. Cheers, And?ol Evain -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: main.cpp URL: <https://stat.ethz.ch/pipermail/r-devel/attachments/20180712/decb3068/attachment.ksh> -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: rmanager.h URL: <https://stat.ethz.ch/pipermail/r-devel/attachments/20180712/decb3068/attachment.h> -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: rmanager.cpp URL: <https://stat.ethz.ch/pipermail/r-devel/attachments/20180712/decb3068/attachment-0001.ksh>
luke-tier@ey m@ili@g off uiow@@edu
2018-Jul-12 22:50 UTC
[Rd] R API for C/C++ initialisation issue appears with update to R.3.5
You might have more luck getting help with a completely self-contained example (no QT in particular) and a complete description of how you built and ran your example. That said, the placement of the call to Rf_endEmbedded looks a little odd. Best, luke On Thu, 12 Jul 2018, And?ol Evain wrote:> Hello everyone, > > I have a C++ program that calls R using R_tryEval, very similarly to what > package RInside does. > It used to work with R.3.4.3 and R.3.4.4. However, since I updated it to > R.3.5.1, R sends an error message: "*Error in < My command > : the base > graphics system is not registered*" for any command related to the > graphics package. > > I made a ticket on stackoverflow about it: https://stackoverflow.com/ > questions/51242993/difference-between-r-3-4-4-and-r-3-5-1-in-r-api-for-c > > But nobody could explain why so far. And after reducing my code further, I > am now enclined to think this is actually a bug. > > The code provided in stackOverflow is already reduced, but not minimal yet. > Since then, I reduced it further to really ensure that it was not an > interference from anything around it. So I removed the GUI and the > callbacks. > Here is a really minimal example attached. > > In its current form, the program just sends the command : par("mar") to > R, and then the command dev.off() . > With R.3.4.4, this program print as output what is expected. No error > occured during evaluation of the command : > > > > > > > > > > *No error occured during eval of "par(\"mar\")"EXAMPLE #1 Output: EXAMPLE > #1 Output: Result is: "5.1"Result is: "5.1"Result is: "5.1"Result is: > "5.1"No error occured during eval of "dev.off()"Result is: "1"* > > But the exact same program with R.3.5.1 gives: > > > > > > *An error occured during eval of "par(\"mar\")"No error occured during eval > of "dev.off()"Result is: "1"* > > The error that occured is not displayed here, since I removed the callbacks > to fetch it, but it was: > *Error in par("mar") : the base graphics system is not registered* > > > I compiled Microsoft Visual C++ Compiler 15.0 (amd64), and uses 64bits > version of R. But previously I also observed the same behovior with 32bits. > I also tried re-installing R from scratch, without effect. > > I am using Windows 10, 64bits > Registry variables PATH and R_HOME are correctly set and points to the > appropriate version of R, installed in the default directory. > > I'd be glad to hear any ideas about potential fixes or workaround. > > Cheers, > > And?ol Evain >-- Luke Tierney Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics and Fax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: luke-tierney at uiowa.edu Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu
Andéol Evain
2018-Jul-13 13:08 UTC
[Rd] R API for C/C++ initialisation issue appears with update to R.3.5
Thanks you very much ! I cleaned up all the Qt dependencies to simplify reproducibility, but when I moved the call to Rf_endEmbedded to the destructor of class RManager instead of right after the callbacks settings, the issue disappeared. It still seems a bit weird that this placement of Rf_endEmbedded was ok for R.3.4, but not for R.3.5. Maybe there used to be some bug that allowed it to work while it shouldn't. And?ol 2018-07-12 23:50 GMT+01:00 <luke-tierney at uiowa.edu>:> You might have more luck getting help with a completely self-contained > example (no QT in particular) and a complete description of how you > built and ran your example. > > That said, the placement of the call to Rf_endEmbedded looks a little > odd. > > Best, > > luke > > On Thu, 12 Jul 2018, And?ol Evain wrote: > > Hello everyone, >> >> I have a C++ program that calls R using R_tryEval, very similarly to what >> package RInside does. >> It used to work with R.3.4.3 and R.3.4.4. However, since I updated it to >> R.3.5.1, R sends an error message: "*Error in < My command > : the base >> graphics system is not registered*" for any command related to the >> graphics package. >> >> I made a ticket on stackoverflow about it: https://stackoverflow.com/ >> questions/51242993/difference-between-r-3-4-4-and-r-3-5-1-in-r-api-for-c >> >> But nobody could explain why so far. And after reducing my code further, I >> am now enclined to think this is actually a bug. >> >> The code provided in stackOverflow is already reduced, but not minimal >> yet. >> Since then, I reduced it further to really ensure that it was not an >> interference from anything around it. So I removed the GUI and the >> callbacks. >> Here is a really minimal example attached. >> >> In its current form, the program just sends the command : par("mar") to >> R, and then the command dev.off() . >> With R.3.4.4, this program print as output what is expected. No error >> occured during evaluation of the command : >> >> >> >> >> >> >> >> >> >> *No error occured during eval of "par(\"mar\")"EXAMPLE #1 Output: EXAMPLE >> #1 Output: Result is: "5.1"Result is: "5.1"Result is: "5.1"Result is: >> "5.1"No error occured during eval of "dev.off()"Result is: "1"* >> >> But the exact same program with R.3.5.1 gives: >> >> >> >> >> >> *An error occured during eval of "par(\"mar\")"No error occured during >> eval >> of "dev.off()"Result is: "1"* >> >> The error that occured is not displayed here, since I removed the >> callbacks >> to fetch it, but it was: >> *Error in par("mar") : the base graphics system is not registered* >> >> >> I compiled Microsoft Visual C++ Compiler 15.0 (amd64), and uses 64bits >> version of R. But previously I also observed the same behovior with >> 32bits. >> I also tried re-installing R from scratch, without effect. >> >> I am using Windows 10, 64bits >> Registry variables PATH and R_HOME are correctly set and points to the >> appropriate version of R, installed in the default directory. >> >> I'd be glad to hear any ideas about potential fixes or workaround. >> >> Cheers, >> >> And?ol Evain >> >> > -- > Luke Tierney > Ralph E. Wareham Professor of Mathematical Sciences > University of Iowa Phone: 319-335-3386 > Department of Statistics and Fax: 319-335-3017 > Actuarial Science > 241 Schaeffer Hall email: luke-tierney at uiowa.edu > Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu[[alternative HTML version deleted]]