0

I wrote this Scheme source file on notepad. I have gambit scheme installed.

(define hello-world
   (lambda ()
         (begin
    (write ‘Hello-World)
            (newline)
    (hello-world))))

I use windows command line. i type in 'gsc hello.scm' in the command line. It spits out a file on my desktop called "hello.o2". I want to see "Hello-World" pop up on my command line. For example, when I compile stuff in c++ it gives me a file called a.exe and I am able to observe it on the command line.

how can I do this with the gambit compiler for scheme?

rnso
  • 23,686
  • 25
  • 112
  • 234
John
  • 1
  • 3

2 Answers2

1

You can create an executable by adding the -exe compiler switch:

gsc -exe hello.scm

will produce hello.exe . Alternatively you can produce the .o1 (or .o2, etc) file and execute it with:

gsc hello.scm
gsi hello
feeley
  • 71
  • 4
  • when i "gsc -exe hello.scm" i get an error message. C:\Users\Owner\Desktop>gsc -exe hello.scm C:\PROGRA~2\Gambit\v4.8.6\lib/libgambit.a(os_b defined reference to `gai_strerrorA' collect2.exe: error: ld returned 1 exit status – John Jan 11 '17 at 21:26
  • This problem is probably due to a difference in mingw version between what you have installed on your machine and what was used to build libgambit.a (apparently the solution is to build Gambit from source yourself: [link](https://webmail.iro.umontreal.ca/pipermail/gambit-list/2013-September/007042.html)). Another solution might be to install the same mingw on your machine. – feeley Jan 17 '17 at 15:05
0

If you want an executable that will run on its own, you need to do a couple of things to make it work correctly.

@;gsi-script %~f0 %*
;
(define hello-world
        (lambda ()
                (begin (write `Hello-World) (newline) (hello-world))))

(define (main)
        (hello-world))

That first line is for DOS/Windows only. The Unix version of that top line is

;#!/usr/local/bin/gsi-script -:d0

Those lines tell the compiler how to execute the code once its compiled.

Also, you need a main procedure. If you're not passing any parameters, then you can use the form I gave you. If you need to pass parameters, you will need to write the main procedure appropriately, noting that all parameters are passed as strings and may need to be parsed or converted before use.

querist
  • 614
  • 3
  • 11