如何使用 Gambit 制作可执行文件 [英] How to make executable File using Gambit

查看:66
本文介绍了如何使用 Gambit 制作可执行文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在记事本上写了这个 Scheme 源文件.我安装了开局计划.

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

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

我使用 Windows 命令行.我在命令行中输入gsc hello.scm".它在我的桌面上吐出一个名为hello.o2"的文件.我想在我的命令行上看到Hello-World"弹出.例如,当我用 C++ 编译东西时,它给了我一个名为 a.exe 的文件,我可以在命令行上观察它.

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.

如何使用 gambit 编译器来实现方案?

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

推荐答案

如果您想要一个可以自行运行的可执行文件,您需要做一些事情才能使其正常工作.

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

第一行仅适用于 DOS/Windows.该顶行的 Unix 版本是

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.

此外,您需要一个 main 过程.如果你没有传递任何参数,那么你可以使用我给你的表格.如果需要传递参数,则需要适当地编写主程序,注意所有参数都是作为字符串传递的,在使用前可能需要解析或转换.

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.

这篇关于如何使用 Gambit 制作可执行文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆