backupcopy
backupcopy

Reputation: 65

How do you compile an executable file in scheme?

I want to make an executable file for the following code. This is scheme written in Dr.racket. How would this be done? It would be best if it can be stand-alone and if I can open it in on iOS and Windows. Thank you very much for your time!

#lang racket

(require racket/gui/base)
(require compiler/embed)


; Make a frame by instantiating the frame% class
(define frame (new frame% [label "GUI"]
                   [width 200]
                   [height 200]))


; Make a static text message in the frame
(define msg (new message% [parent frame]
                          [label "This box is empty"]))


; Show the frame by calling its show method
(send frame show #t)

Upvotes: 5

Views: 4899

Answers (1)

Óscar López
Óscar López

Reputation: 235984

As pointed by @dyoo, in Racket you can create an executable from the menu and (depending on the selected/available options) pack the required libraries; read the instructions. Also you can create executables for other platforms using command line tools.

For a more general and portable solution, consider compiling the code to C first and then compile from C to a native executable; take a look at the raco tool (section 9.3), or look at a Scheme implementation designed for easily compiling to C, such as Chicken Scheme or Gambit Scheme.

Getting the code to run under iOS might be trickier, a quick search returned a Gambit REPL for iOS, give it a try but I don't think there's support for compiling to native Objective-C code, although Gambit claims to have "full integration support for C++ and Objective-C compilers", you'll have to experiment with it a bit.

Finally, notice that GUI code specific to Racket (like the one in the question) will almost certainly be non-portable across different Scheme implementations/platforms...

Upvotes: 6

Related Questions