R Dynamic Library (Windows)

.. fixed up to work on Windows too.

.. needed to add a couple of functions used by Windows;
   getRUser(), get_R_HOME() and getDLLVersion().

.. also needed to add a path to the DLL that included the
   address space (x64 or i386).
This commit is contained in:
Mark Liversedge
2016-05-14 08:04:11 +01:00
parent 6782f5a393
commit dba02cc49f
4 changed files with 36 additions and 10 deletions

View File

@@ -83,7 +83,6 @@ REmbed::REmbed(const bool verbose, const bool interactive) : verbose(verbose), i
setenv("R_HOME", configR_HOME.toLatin1().constData(), 1);
}
}
// fire up R
const char *R_argv[] = {name, "--gui=none", "--no-save",
"--no-readline", "--silent", "--vanilla", "--slave"};

View File

@@ -130,6 +130,10 @@ Prot_GC_ptr_R_ResetConsole ptr_GC_ptr_R_ResetConsole;
Prot_GC_ptr_R_FlushConsole ptr_GC_ptr_R_FlushConsole;
Prot_GC_ptr_R_ClearerrConsole ptr_GC_ptr_R_ClearerrConsole;
Prot_GC_ptr_R_Busy ptr_GC_ptr_R_Busy;
#else
Prot_GC_getDLLVersion ptr_GC_getDLLVersion;
Prot_GC_getRUser ptr_GC_getRUser;
Prot_GC_get_R_HOME ptr_GC_get_R_HOME;
#endif
// R data
@@ -272,8 +276,11 @@ RLibrary::load()
name = "lib/libR.so";
#endif
#ifdef WIN32
if (home == "") home = "/Program Files/R/";
name = "bin/R.dll";
#if defined(_M_X64) || defined (WIN64)
name = QString("bin/x64/R.dll");
#else
name = QString("bin/i386/R.dll");
#endif
#endif
#ifdef Q_OS_MAC
if (home == "") home= "/Library/Frameworks/R.framework/Resources";
@@ -365,7 +372,12 @@ RLibrary::load()
ptr_GC_ptr_R_FlushConsole = Prot_GC_ptr_R_FlushConsole(resolve("ptr_R_FlushConsole"));
ptr_GC_ptr_R_ClearerrConsole = Prot_GC_ptr_R_ClearerrConsole(resolve("ptr_R_ClearerrConsole"));
ptr_GC_ptr_R_Busy = Prot_GC_ptr_R_Busy(resolve("ptr_R_Busy"));
#else
ptr_GC_getDLLVersion = Prot_GC_getDLLVersion(resolve("getDLLVersion"));
ptr_GC_getRUser = Prot_GC_getRUser(resolve("getRUser"));
ptr_GC_get_R_HOME = Prot_GC_get_R_HOME(resolve("get_R_HOME"));
#endif
// did it work -- resolve sets to false if symbols won't load
return loaded;
}

View File

@@ -79,6 +79,13 @@ extern void (*(*ptr_GC_ptr_R_ResetConsole))(void);
extern void (*(*ptr_GC_ptr_R_FlushConsole))(void);
extern void (*(*ptr_GC_ptr_R_ClearerrConsole))(void);
extern void (*(*ptr_GC_ptr_R_Busy))(int);
#else
typedef char *(*Prot_GC_getDLLVersion)(void);
typedef char *(*Prot_GC_getRUser)(void);
typedef char *(*Prot_GC_get_R_HOME)(void);
extern Prot_GC_getDLLVersion ptr_GC_getDLLVersion;
extern Prot_GC_getRUser ptr_GC_getRUser;
extern Prot_GC_get_R_HOME ptr_GC_get_R_HOME;
#endif
// R Data
@@ -160,6 +167,11 @@ extern double *pGC_R_NaReal; // XXX TODO NaReal value
#define ptr_R_ClearerrConsole (*ptr_GC_ptr_R_ClearerrConsole)
#define ptr_R_Busy (*ptr_GC_ptr_R_Busy)
#define R_registerRoutines GC_R_registerRoutines
#ifdef WIN32
#define getDLLVersion (*ptr_GC_getDLLVersion)
#define getRUser (*ptr_GC_getRUser)
#define get_R_HOME (*ptr_GC_get_R_HOME)
#endif
// data wrangling and manipulation
#define Rf_allocVector GC_Rf_allocVector

View File

@@ -243,14 +243,17 @@ contains(DEFINES, "GC_WANT_R") {
## both 32 and 64 bit
RCPPFLAGS = -I$$R_HOME/include
# 64 Bit Build
contains(QMAKE_TARGET.arch, x86_64):{
LIBS += $$R_HOME/bin/x64/R.lib
}
!contains(DEFINES, "GC_WANT_R_DYNAMIC") {
# 32 Bit Build
!contains(QMAKE_TARGET.arch, x86_64):{
LIBS += $$R_HOME/bin/i386/R.lib
# 64 Bit Build
contains(QMAKE_TARGET.arch, x86_64):{
LIBS += $$R_HOME/bin/x64/R.lib
}
# 32 Bit Build
!contains(QMAKE_TARGET.arch, x86_64):{
LIBS += $$R_HOME/bin/i386/R.lib
}
}
} else {