Is it possible to cross-compile Racket?

131 views
Skip to first unread message

Leff Ivanov

unread,
Jan 26, 2018, 7:40:45 AM1/26/18
to Racket Users
Is it possible for example running DrRacket on Windows to generate standalone native executables for Mac OSX and some generic Linux distribution?

Matthew Flatt

unread,
Jan 26, 2018, 8:19:52 AM1/26/18
to Leff Ivanov, Racket Users
It should be possible from the command line, although there's a lot of
room to improve the tooling.


See

http://docs.racket-lang.org/raco/cross-system.html?q=raco%20exe

for the main hint. When you want to use your Windows installation and
pretend that you're running on some target platform (e.g., to generate
executables), you use

racket -C -G ‹cross-dir›/etc -X ‹cross-dir›/collects -l- raco ....

where ‹cross-dir› is an installation for the target platform.


To get a ‹cross-dir›, unpack the corresponding "Minimal Racket" tarball
from

http://download.racket-lang.org/releases/6.11/

Most likely, you'll need some packages in that installation to use for
your executable, so you'll set up the packages for a ‹cross-dir› with

racket -C -G ‹cross-dir›/etc -X ‹cross-dir›/collects -l- raco pkg install ....


When whatever packages your program uses are ready in ‹cross-dir›, then

racket -C -G ‹cross-dir›/etc -X ‹cross-dir›/collects -l- raco exe ....
racket -C -G ‹cross-dir›/etc -X ‹cross-dir›/collects -l- raco dist ....

should work to produce an executable and then a distribution.

Matt Jadud

unread,
Jan 26, 2018, 9:19:54 AM1/26/18
to Matthew Flatt, Leff Ivanov, Racket Users
I've wondered this many times, and never investigated it.

Thank you both for the question and answer. 
Reply all
Reply to author
Forward
0 new messages