{"action":"created","issue":{"url":"https://api.github.com/repos/swig/swig/issues/345","labels_url":"https://api.github.com/repos/swig/swig/issues/345/labels{/name}","comments_url":"https://api.github.com/repos/swig/swig/issues/345/comments","events_url":"https://api.github.com/repos/swig/swig/issues/345/events","html_url":"https://github.com/swig/swig/issues/345","id":58668787,"number":345,"title":"[R] windows support very broken","user":{"login":"ibell","id":1859947,"avatar_url":"https://avatars.githubusercontent.com/u/1859947?v=3","gravatar_id":"","url":"https://api.github.com/users/ibell","html_url":"https://github.com/ibell","followers_url":"https://api.github.com/users/ibell/followers","following_url":"https://api.github.com/users/ibell/following{/other_user}","gists_url":"https://api.github.com/users/ibell/gists{/gist_id}","starred_url":"https://api.github.com/users/ibell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ibell/subscriptions","organizations_url":"https://api.github.com/users/ibell/orgs","repos_url":"https://api.github.com/users/ibell/repos","events_url":"https://api.github.com/users/ibell/events{/privacy}","received_events_url":"https://api.github.com/users/ibell/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-02-23T23:41:07Z","updated_at":"2015-03-10T07:27:22Z","closed_at":null,"body":"Aside from the fact that there are essentially no docs for swig+R, nothing seems to work on windows. I'm using the files shown below.\r\n\r\nProblem 1: windows build of R tries to use ``make`` whereas on windows, ``mingw32-make`` is the typical command line program that should be used.  Therefore, following the docs, this \r\n```\r\nswig -r example.i\r\nset PKG_LIBS=\"example.c\" \r\n\"c:\\Program Files\\R\\R-3.1.2\\bin\\x64\\R\" CMD SHLIB example_wrap.c\r\n```\r\nfails with the message\r\n```\r\nWarning message:\r\nrunning command 'make -f \"c:/PROGRA~1/R/R-3.1.2/etc/x64/Makeconf\" -f \"c:/PROGRA~1/R/R-3.1.2/share/make/winshlib.mk\" SHLIB=\"example_wrap.dll\" WIN=64 TCLBIN=64 OBJECTS=\"example_wrap.\r\no\"' had status 127\r\n```\r\nProblem 2: windows build of R has hardcoded include paths that are incorrect, so even if you run the failing make command at the command prompt, it then dies at this stage:\r\n```\r\nC:\\Users\\ihb\\Documents\\Code\\R_swig>mingw32-make -f \"c:/PROGRA~1/R/R-3.1.2/etc/x64/Makeconf\" -f \"c:/PROGRA~1/R/R-3.1.2/share/make/winshlib.mk\" SHLIB=\"example_wrap.dll\" WIN=64 TCLBIN\r\n=64 OBJECTS=\"example_wrap.o\"\r\ngcc -m64 -I\"/include\" -DNDEBUG     -I\"d:/RCompile/CRANpkg/extralibs64/local/include\"     -O2 -Wall  -std=gnu99 -mtune=core2 -c example_wrap.c -o example_wrap.o\r\nexample_wrap.c:715:22: fatal error: Rdefines.h: No such file or directory\r\n #include <Rdefines.h>\r\n                      ^\r\ncompilation terminated.\r\nc:/PROGRA~1/R/R-3.1.2/etc/x64/Makeconf:180: recipe for target 'example_wrap.o' failed\r\nmingw32-make: *** [example_wrap.o] Error 1\r\n```\r\nProblem 3: Even when you do succeed to manually build the module (which I will do anyway using CMake) using this\r\n```\r\nswig -r example.i\r\ngcc -m64 -I\"/include\" -DNDEBUG -I\"C:/Program Files/R/R-3.1.2/include\" -O2 -Wall  -std=gnu99 -mtune=core2 -c example_wrap.c -o example_wrap.o\r\ngcc -shared -o example_wrap.dll example_wrap.o example.c -L\"C:/Program Files/R/R-3.1.2/bin/x64\" -lR\r\n```\r\nwhen I try to use the module, it gives me this\r\n```\r\n> dyn.load(\"example_wrap.dll\")\r\n> source(\"example.R\")\r\nCreating a generic function for 'print' from package 'base' in the global environment\r\n> print(fact(4))\r\nError in print(fact(4)) :\r\n  error in evaluating the argument 'x' in selecting a method for function 'print': Error in .Call(\"R_swig_fact\", s_arg1, as.logical(.copy), PACKAGE = \"example\") :\r\n  \"R_swig_fact\" not available for .Call() for package \"example\"\r\nCalls: fact -> .Call\r\nExecution halted\r\n```\r\n\r\n**The files**\r\nexample.c\r\n```\r\n/* Compute factorial of n */\r\nint  fact(int n) {\r\n        if (n <= 1) return 1;\r\n        else return n*fact(n-1);\r\n}\r\n```\r\nexample.i\r\n```\r\n%module example\r\n%{\r\n/* Put headers and other declarations here */\r\nextern int    fact(int);\r\n%}\r\nextern int    fact(int);\r\n```\r\ntestR.r\r\n```\r\ndyn.load(\"example_wrap.dll\")\r\nsource(\"example.R\")\r\nprint(fact(4))\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/swig/swig/issues/comments/78006961","html_url":"https://github.com/swig/swig/issues/345#issuecomment-78006961","issue_url":"https://api.github.com/repos/swig/swig/issues/345","id":78006961,"user":{"login":"ibell","id":1859947,"avatar_url":"https://avatars.githubusercontent.com/u/1859947?v=3","gravatar_id":"","url":"https://api.github.com/users/ibell","html_url":"https://github.com/ibell","followers_url":"https://api.github.com/users/ibell/followers","following_url":"https://api.github.com/users/ibell/following{/other_user}","gists_url":"https://api.github.com/users/ibell/gists{/gist_id}","starred_url":"https://api.github.com/users/ibell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ibell/subscriptions","organizations_url":"https://api.github.com/users/ibell/orgs","repos_url":"https://api.github.com/users/ibell/repos","events_url":"https://api.github.com/users/ibell/events{/privacy}","received_events_url":"https://api.github.com/users/ibell/received_events","type":"User","site_admin":false},"created_at":"2015-03-10T07:27:22Z","updated_at":"2015-03-10T07:27:22Z","body":"Looking back at my code, I might have missed a second ``-m64`` flag on link.  Let me have another go at this."}}