Skip to content

Building packages 4 Windows with macbook pro

5 messages · Hervé Pagès, Jean Thioulouse, Simon Urbanek +1 more

#
Hello to all,

I am a package developper and I would like to 
know what is the best way to build package 
binaries for both Windows and Mac installation of 
R, using a macbook pro?

The command I am presently using to create and build my packages binaries is :

"R CMD BUILD ~/foo"  -> This produce foo.tar.gz 
which cannot be used in a windows installation of 
R.

I would be very pleased if you could enligthen me

Sebastien
#
Hi Sebastien,
Sebastien Durand wrote:
You probably mean you are using 'R CMD build' ("BUILD" in upper case doesn't work
on my system) don't you?

I can only give a partial answer...

'R CMD build' by default is not intended to build a binary package but a source
package (yes, having called this "build" doesn't help but you will get used to it ;-)).

As you've found out, 'R CMD build ~/foo' produces something like foo_0.9.5.tar.gz
which is a _source_ package (source packages are always suffixed with _X.Y.Z.tar.gz).
This command ('R CMD build') is platform independent: it will produced the same tarball
(except maybe for the vignette, more on this below) on Unix/Linux, Windows and Mac OS X.
But in order to use 'R CMD build' you need to have the R development tools on your system
(compilers, make, Perl, etc...). Note that the exact requirements _are_ platform dependent
(they can be tricky to install on Windows).

So now you might wonder why those development tools are required if the resulting tarball
(foo_0.9.5.tar.gz) is more or less the result of packaging the source directory with 'tar zcf'.
Strangely, and as you might have already noticed, for some packages, it seems that 'R CMD build'
is invoking the C, C++ or Fortran compilers! This happens when a package contains a Sweave
vignette (.Rnw file): in order to create the PDF version of the vignette (so it can be included
in the packaging), 'R CMD build' needs to temporarily install the package. Hence the compilation
when the package contains native code.

Binary packages are of course platform dependent. They have the .zip suffix on Windows and
the .tgz suffix on Mac OS X. Note that Unix/Linux users are always expected to install a
package from source (from the source tarball) so you only need to get into the trouble of
building binary packages if you want to make your packages available to the Mac OS X and
Windows users that don't have the R development tools installed (those who have them can
always install from source with R CMD INSTALL foo_0.9.5.tar.gz).

There are different methods to build them:

  (1) Recommended on Windows: 'R CMD INSTALL --build foo_0.9.5.tar.gz' will
      produce foo_0.9.5.zip on Windows

  (2) 'R CMD INSTALL --library=LIB foo_0.9.5.tar.gz', then manually zip (on Windows)
      or tar the LIB/foo directory. When you use this method, it is your responsability
      to properly name the resulting file.

  (3) R CMD build --binary ~/foo

See
  o R CMD build --help
  o R CMD INSTALL --help
  o "Checking and building packages" in the "Writing R Extensions" manual
    http://cran.r-project.org/doc/manuals/R-exts.html#Checking-and-building-packages
for more information.

Also, it's a good practice to always 'R CMD check' (see R CMD check --help) your packages
before building and distributing the binary versions.

Hopefully someone on this list will be able to tell you what's the recommended way to build
binary packages on Mac OS X (they use some modify version of (2) AFAIK).

Cheers,
H.
1 day later
#
At 15:42 -0400 9/05/07, Sebastien Durand wrote:
I use the "R CMD build --binary" command under Windows in Parallels
Desktop for Mac. It works quite well on my macbook with 2Gb RAM. See http://www.parallels.com/

You might want to check VirtualBox too : http://www.virtualbox.org/
which is now free (GNU licence).

Of course, you must have the complete R development tools setup under
the guest Windows OS, which is even trickier than on MacOS (as opposed
to Linux).

I also have a Linux Debian installed in Parallels Desktop and R CMD
build --binary works well too.

Jean
#
FWIW: you can cross-compile Windows packages on a Mac fairly easily.  
All you need is current MinGW, everything else is already in the  
Xcode tools. The only drawback is that you won't get CHM help by  
default - if you want it, you have to use hhc which is a Windows  
program, but you can run it in Wine thus you don't need Windows at all.

Cheers,
Simon
On May 11, 2007, at 9:57 AM, Jean Thioulouse wrote:

            
4 days later
#
Thank you all for your great replies.

Cheers