mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-14 00:28:42 +00:00
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:
@@ -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"};
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
17
src/src.pro
17
src/src.pro
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user