Hi,

 

  I'am trying to use R in my Cpp project but I fail. 

 

 First I try to include R.h for loading statically R.dll but there is
conflict with windows definition of Error.

 

 Second, I try to use dynamically that Dll but, I can't use allocVector
(toto here). The error message said that I try to read a no allocate
zone.

 

This is my code.

 

typedef SEXP (*MYPROC)(SEXPTYPE,int);

MYPROC toto;

 

int _tmain(int argc, _TCHAR* argv[])

{  

      HINSTANCE hLib=LoadLibrary("R.DLL");

      if(hLib==NULL) {

           cout << "Unable to load library!" << endl;

           getch();

           return 0;

      }

      char mod[MAXMODULE];

      GetModuleFileName((HMODULE)hLib, (LPTSTR)mod, MAXMODULE);

      cout << "Library loaded: " << mod << endl;

      getch();

      toto=(MYPROC)GetProcAddress((HMODULE)hLib, "Rf_allocVector");

      if((toto==NULL)) {

           cout << "Unable to load function(s)." << endl;

           FreeLibrary((HMODULE)hLib);

           return 1;

      }

       SEXP ab;// = new SEXPREC;

       ab = (toto) (REALXP,2);

 

}

 

Third I have download R COM.

 

I' am looking for counsel. Am I compulsory to use   R com or not?

If not how can I improve my code?

Do you have an idea?

 

JBB

 

 


        [[alternative HTML version deleted]]

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to