[R] Rf_initEmbeddedR in Windows

yuting@iastate.edu yuting at iastate.edu
Thu Sep 22 21:10:41 CEST 2005


Hi All

My C++/linux program uses Rf_initEmbeddedR to start R and then calls some
R functions. Now I try to port it to Windows. Give the fact that
Rf_initEmbeddedR is missing in Windows, I try to use the implmentation in
Rserve by Simon Urbanek. When I build in MS Visual Studio, I get the
following linking error

error LNK2019: unresolved external symbol __imp__putenv referenced in
function _Rf_initEmbeddedR
error LNK2019: unresolved external symbol __imp__UserBreak referenced in
function _my_onintr
error LNK2019: unresolved external symbol _getDLLVersion referenced in
function _Rf_initEmbeddedR
error LNK2019: unresolved external symbol _R_DefParams referenced in
function _Rf_initEmbeddedR
error LNK2019: unresolved external symbol _R_SetParams referenced in
function _Rf_initEmbeddedR
error LNK2019: unresolved external symbol _R_SizeFromEnv referenced in
function _Rf_initEmbeddedR
error LNK2019: unresolved external symbol _setup_Rmainloop referenced in
function _Rf_initEmbeddedR
error LNK2019: unresolved external symbol _setup_term_ui referenced in
function _Rf_initEmbeddedR

I think the error come from the following declaration of functions calling
into R.dll and the missing of R.lib corresponding to R.dll.
extern char	*getDLLVersion();
extern void	R_DefParams(Rstart);
extern void  R_SetParams(Rstart);
extern void  setup_term_ui(void);
extern void  ProcessEvents(void);
extern void  end_Rmainloop(void), R_ReplDLLinit(void);
extern int  R_ReplDLLdo1();
extern void  run_Rmainloop(void);

Then I google it, I find some solution of Borland C++ Builder, i.e. using
implib to generate R.lib. The only place where  I can find implib is at 
(http://www.geocities.com/SiliconValley/5806/download.htm#IMPLIB) and the
commond generates a error as below
C:\Program Files\R\rw2011\bin>IMPLIB32.EXE R.dll
ImpLib32 Version 1.02 - ImpLib for Win32
Copyright (c) 1996-97 by Markus Seger (mseger at kagi.com)
Creating R.lib...
'c:\Program' is not recognized as an internal or external command,
operable program or batch file.
'c:\Program' is not recognized as an internal or external command,
operable program or batch file.

My questios are
1) Is it a right way to generate R.lib to remove the linking error.
2) If yes, how can I generate the R.lib valid for MS Visual Studio
3) If not, how can I call the functions directly in R.dll


Any helps are appreciated!

YUting




More information about the R-help mailing list