Build-Exe

(build-exe platform module) -> str

Allows for the creation of executable binaries based on MOSVM module files. This cannot be completed entirely from within MOSVM, so a basic knowledge of the command-line interface for your host operating system is required

For this example, we will use the basic chat-server found in the examples directory, and we will compile it on our Technical Writer's Apple OS X system.

First, we need a compiled version of the chat-server source:

>> (import "lib/mosc")
:: #f
>> (mosc "examples/chatter")
:: #f

Next, we need to invoke the "chatter" function defined in that module. So, using our text-editor of choice, we create the following program:

(import "examples/chatter")
(chatter 9191)

and save it as moschat.ms, in our mosvm directory.

>> (mosc "moschat")
:: #f

Now, we create the file that will become a binary executable.

>> (import "lib/build")
:: #f
>> (import "lib/file-port")
:: #f
>> (define a (open-output-file "moschatexe"))
:: #f
>> (write (build-exe "darwin-ppc" "moschat") a)
:: #f
>> (close a)
:: #f

Next, we turn to the Darwin command line.

Epona:~/mosvm ericjordan$ chmod u+x moschatexe
Epona:~/mosvm ericjordan$ ./moschatexe

This window of the terminal is now fully engaged with moschatexe. Opening another instance of the window:

Epona:~ ericjordan$ telnet 10.0.1.4 9191
Trying 10.0.1.4...
Connected to 10.0.1.4.
Escape character is '^]'.
User name? Eric
Welcome, Eric
And as you can see, you now have a basic chat server!
Eric says, "And as you can see, you now have a basic chat server!"