<div>Hi all,<br> <br>I have a problem of Rf_initEmbeddedR function.</div>
<div> </div>
<div>I've tried with:</div>
<div> try <br> {<br> int Argc1 = 1;<br> char *Argv1[] = {"Rtest_1"};<br> int Argc2 = 1;<br> char *Argv2[] = {"Rtest_2"};</div>
<div> </div>
<div> // Init R(first)<br> Rf_initEmbeddedR(Argc1, Argv1);</div>
<div> </div>
<div> // R package load<br> SEXP e = R_NilValue;<br> SEXP r = R_NilValue;<br> PROTECT(e = lang2(install("source"), mkString("hreg.r")));<br> r = R_tryEval(e, R_GlobalEnv, NULL); // -----> success<br>
UNPROTECT(1);</div>
<div> // Function load<br> SEXP fun;<br> PROTECT(e = allocVector(LANGSXP, 3));<br> fun = findFun(install("hreg"), R_GlobalEnv);<br> if(fun == R_NilValue) // -----> success<br> {<br> UNPROTECT(1);<br>
throw std::range_error("R Function not found");<br> }<br> SETCAR(e, fun);<br> UNPROTECT(1);</div>
<div> </div>
<div> // End R<br> R_dot_Last();<br> Rf_endEmbeddedR(0);<br> R_gc();</div>
<div> </div>
<div> /////////////////////////////</div>
<div> // Init R(second)<br> Rf_initEmbeddedR(Argc2, Argv2);</div>
<div> </div>
<div> // R package load<br> e = R_NilValue;<br> r = R_NilValue;<br> PROTECT(e = lang2(install("source"), mkString("hbnreg.R")));<br> r = R_tryEval(e, R_GlobalEnv, NULL); // -----> NULL return<br>
UNPROTECT(1);</div>
<div> // Function load<br> PROTECT(e = allocVector(LANGSXP, 3));<br> fun = findFun(install("hbnreg"), R_GlobalEnv); // -----> Exception Error<br> if(fun == R_NilValue) <br> {<br> UNPROTECT(1);<br> throw std::range_error("R Function not found");<br>
}<br> SETCAR(e, fun);<br> UNPROTECT(1);</div>
<div> </div>
<div> // End R<br> R_dot_Last();<br> Rf_endEmbeddedR(0);<br> R_gc();</div>
<div> } <br> catch(std::exception& ex) <br> {<br> m_strErrMsg = ex.what();<br> return S_FALSE;<br> } <br> catch(...) <br> {<br> m_strErrMsg = "Exception: unknown reason";<br> return S_FALSE;<br> }<br></div>
<div> </div>
<div>-----------------------------<br>my work environment :<br>R version : 2.11.1<br>Development Language : VC++<br>OS : WinXP Pro sp3<br> <br>Thanks and best regards.<br> <br>Young-Ju, Park<br>from Korea </div>