How to Cross Compile R Packages for MACos from a Linux Environment

How do I cross compile R packages for MacOS from a Linux environment?

By first building a gcc crosscompiler -- see its documentation.

Available libraries may be a limiting factor, though. You'd have to rebuild everything from OS X you'd like to link against.

How to cross compile from Mac OS X to Linux x86?

Your simplest solution is to just run CentOS 5.3 in a VM (e.g. Sun VirtualBox). This requires minimal setup, has quite reasonable overhead (assuming an Intel Mac), and you'll be able to actually test and debug what you are building.

If you really insist on cross-compiling, you must build a cross-compiler. Instructions are here and here, but beware: it will likely take you several days to get it right, and then you'll still need a VM to test the result, so I don't see any point in doing it that way.

Creating package for Mac in Windows / Linux

The package that was created using R CMD build can be installed on other OS types. Even if your package contains source code other than R (c or c++) this is the case. Only when you create a binary distribution (I think by adding --binary to the r cmd build call) the package becomes platform specific. The tools needed to build packages are often already installed under linux or mac. So if you create a source distribution, it should work under all the major distributions. To create a mac binary, you need either a mac, or create a cross-compiler environment. The second option could be quite a challenge, I say you could give to a google. Do note that if you upload your package to CRAN, all building of packages is done for you.

Cross compile Go on OSX?

With Go 1.5 they seem to have improved the cross compilation process, meaning it is built in now. No ./make.bash-ing or brew-ing required. The process is described here but for the TLDR-ers (like me) out there: you just set the GOOS and the GOARCH environment variables and run the go build.

For the even lazier copy-pasters (like me) out there, do something like this if you're on a *nix system:

env GOOS=linux GOARCH=arm go build -v github.com/path/to/your/app

You even learned the env trick, which let you set environment variables for that command only, completely free of charge.



Related Topics



Leave a reply



Submit