Linking C and R in Windows -


i trying link r , c in windows while following instructions on web page

http://mcglinn.web.unc.edu/blog/linking-c-with-r-in-windows/

i have r, rtools , turboc4 in separate folders in c drive. system 64bits have tried on both 32 , 64 bit r.

i have written following code in c

#include <r.h>  void hello(int *n)  { int i;     for(i=0; i<=*n; i++){      rprintf("hello, world!this hell though i'm enjoying it\n");      }  } 

and saved name world.c on separate file path c:\turboc4\tc\bin

i have written following r code

hello2 <- function(n) { .c("hello", as.integer(n))  }  hello2(5) 

and save name world.r.

now have prepare window. have downloaded rtools33.exe here https://cran.r-project.org/bin/windows/rtools/

and set environment variables manually through command

path=c:\rtools\bin;c:\rtools\gcc-4.6.3\bin;c:\program files\r\r-3.2.2\bin\i386;  

then reinstalled system

before calling c code in r have compile c code in cmd. write following command change directory world.c saved

cd c:\users\turboc4\tc\bin 

which successful when try compile

c:\users\turboc4\tc\bin> r cmd shlib world.c 

i following error. " 'r' not recognized internal or external command, operable ". have tried compile world.c in c , got these 2 errors. "unable open #include r.h>" , "function rprintf should have prototype".

setting environment problem think facing problem. have checked rtools33.exe compatible r 3.2.x , later. getting same error on cmd. have tried different paths environments , have tried different r versions r- 3.2.2, r- 3.2.0, 2.15.3, 2.15.0. when write

"install.packages("rtools33") in of these r version, got following warning message

warning in install.packages :package ‘rtools33’ not available (for r version     2.15.0)"  

the reason using different rs when download rtools folder there version file says "rtools collection 3.3.0.1959". think maybe compatibility issue.

there instructions on github page https://github.com/stan-dev/rstan/wiki/install-rtools-for-windows "for installing rtools, attention needs paid in step can edit system path c++ compiler included in rtools can used r. indicated following step, need check option (not manually edit system path. once option checked, system path edited include important folders of rtools installation process)."

so, have uninstalled rtools , while reinstalling have checked option button , retried in vein.

i have checked sys.getenv('path') , got

c:\\\\\\\\rtools\\\\\\\\gcc-4.6.3\\\\\\\\bin;c:\\\\\\\\rtools\\\\\\\\bin; 

i have tried setting path in control pannel-> useraccountandfamilysafety->useraccounts->change my
environment variable , creating new variable above path. still not able direct r c++ compiler. can please figure out mistake?

this problem solved. there minor mistake of defining environment variable. correct definition follows.

c:\rtools\bin;c:\rtools\gcc-4.6.3\bin;c:\program files\r\r-3.2.2\bin\i386;  

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -