Hin-Tak Leung
2009-Jul-06 20:25 UTC
[Rd] success(?) with cross-compiling R package with R 2.9.1
Hi, (I am not longer on R-devel - please CC:) Just when Fedora 11 is shipping a gcc 4.4 based cross-compiler - the last major distro to ship a cross-compiler, but the first to ship a gcc 4.4- one.(both Suse & Debian has been so so for a while, and I expect Ubuntu as well), and the mingw people has finally released gcc 4.4 mingw builds, I am a little disappointed to find that cross-compling support has been withdrawn from R in mid-January. I can't find any discussions... anyway, so I set about trying to revert the changes. The bulk of the cross-compiling support was removed in three svn commits - GIT is very good as a svn client! - 'remove support for cross-building' - r47689 'makefile reorganization part 3' - r47698 'remove more vestiges of cross-building' - r48109 The last one can be reverted cleanly against trunk, the first with a little manual fiddle, but the 2nd one is a pain. Then I worked that that copying just this list over from 2.8.1 is sufficient to restore R package cross-compiling ability: (half of these files are removed in 2.9.1, half are different) ------------------ share/perl/build-help-windows.pl share/perl/R/Rdlists.pm src/gnuwin32/ src/gnuwin32/makeDllRes.pl src/gnuwin32/Makefile src/gnuwin32/pwd.pl src/gnuwin32/MkRules src/gnuwin32/MakeDll src/gnuwin32/help/ src/gnuwin32/help/Makefile src/gnuwin32/MakePkg ------------------ Then I thought there must be a simplier way - most of R 2.9.1 isn't platform-sensitive any more (in fact that seems to be the direction of the changes), the important part is just building dll. So lastly, I found that just by building the DLL and drop it into the libs folder of the unix build, the result seems to work with windows (or at least, in wine). The procedure for building the package DLL is this: 1) insert into the file "src/gnuwin32/MkRules", just before "end of user-customizable parts", these two lines: BINPREF=i386-mingw32- R_EXE=/usr/bin/R 2) copy src/gnuwin32/MakeDll and src/gnuwin32/MkRules from <R_src_top> to <win32_R_top> (the win32 R distribution no longer carries those two files - it would be nice if it does.. very subtle hint!) 3) Run make -C <package_src_top>/src/ \ -f <win32_R_top>/src/gnuwin32/MakeDll \ RHOME=<win32_R_top> \ DLLNAME=<package_name> I guess my question is, other than that this is neither a supported nor recommended way of building win32 R packages, is there any forseeable problem with it? R 2.9.1 seems to be sane enough that just dropping the <package>.dll into the unix build, next to the libs/<package>.so, results in an R package usable with win32 R. I suppose there are more people than just me who would like cross-compiling R packages to work - using a separate windows box or the win-builder on-line service has a fair amount of round-trip time, compared to cross-compiling (and try it out in wine). Cheers, Hin-Tak