Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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)
like image 351
backupcopy Avatar asked Jan 17 '13 05:01

backupcopy


People also ask

How does a compiler create an executable?

A compiler takes the program code (source code) and converts the source code to a machine language module (called an object file). Another specialized program, called a linker, combines this object file with other previously compiled object files (in particular run-time modules) to create an executable file.

What is an executable file compiler?

The Compiler the supports generation of procedural COBOL code to Java . class files and also offers object-oriented extensions to the COBOL language. Executable code. You produce executable code by compiling and linking in one step. An executable file has a filename extension of .exe.

Does compiling create an executable?

The compiler (or more specifically, the linker) creates the executable. The format of the file generally vary depending on the operating system. If you understand the concept of a structure, this is the same, only within a file.

How is an executable file executed?

In order to be executed by the system (such as an operating system, firmware, or boot loader), an executable file must conform to the system's application binary interface (ABI). In simple interfaces, a file is executed by loading it into memory and jumping to the start of the address space and executing from there.


1 Answers

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...

like image 55
Óscar López Avatar answered Oct 03 '22 06:10

Óscar López