[gambit-list] Building issues with 4.1.2 under Windows

Marc Feeley feeley at iro.umontreal.ca
Fri Dec 28 09:45:52 EST 2007


On 28-Dec-07, at 3:45 AM, Nick wrote:

> Hi!
>
> Although the Gambit compiler is quite cool (especially I like code  
> performance, that it produces :-) ), it has a few quirks and I tried  
> to fix them.
>
> I have Visual Studio 2003 and wanted to build Gambit-C with it. So I  
> downloaded the gambc-v4_1_2.tgz package, and of course it didn't  
> compile out of box, because there is no ready to use "gambit.h" in  
> the package, because "gambit.h" should be generated with "configure".

For the include/gambit.h file, you can create it with the commands

echo #ifndef ___VOIDSTAR_WIDTH                > include\gambit.h
echo #define ___VOIDSTAR_WIDTH ___LONG_WIDTH >> include\gambit.h
echo #endif                                  >> include\gambit.h
echo #ifndef ___MAX_CHR                      >> include\gambit.h
echo #define ___MAX_CHR 0x10ffff             >> include\gambit.h
echo #endif                                  >> include\gambit.h
type include\gambit.h.in                     >> include\gambit.h

By the way, have you tried using one of the Windows installers to  
avoid building Gambit from source?

> Ok, I've downloaded and installed msys (only, i.e. without mingw),  
> and run the usual sequence:
> > sh
> sh-2.04$ configure
> sh-2.04$ make
> sh-2.04$ make install
> The resulting distribution is working fine, except one thing.  
> gsc.exe and gsi.exe are opening new console window and the window  
> immediately disappears after gs(c|i) finishes. In case of some  
> errors it is impossible to catch the error messages. Even piping  
> (gsc ... > out.txt) doesn't help, "out.txt" just doesn't being  
> created.

If you want error messages to be sent to stdout you must use the -:d-  
runtime option or the -:dr option, i.e.

    % gsi -:d- foobar.scm > out.txt

(this will send the error message to the file out.txt)

and

    % gsi -:dr foobar.scm < input > output

(this will start a REPL in the new console)

I admit it is annoying that the newly created console vanishes  
immediately after displaying the error message and I will look into a  
fix.

For your information the console is being created because Gambit was  
designed to allow debugging programs which redirect stdin and stdout.   
When you use the -:dr option, you will get a REPL at the console which  
is independent from stdin and stdout, so you can type REPL commands  
without any interference with stdin.  On UNIX it is the "controlling  
terminal" that is used.

> Previously, I've compiled version 4.1.0 and it built under VS2003  
> without single problem. So I decided to compile version 4.1.2 under  
> VS too but it fails to compile.
>
> After some investigation I created new Visual Studio project files,  
> and with them everything goes ok. I created two additional projects,  
> ~~/gsc/libgsc.vcproj and ~~/gsi/libgsi.vcproj with the following  
> dependence graph:
> lib -> gsc
> libgsc -> gsc
> lib -> gsi
> libgsi -> gsi
> Please, see the attachment with new project files.

Thank you for the project file.  I will check it out.  You seem to  
have missed this information in the INSTALL.txt file:

4) Building on Microsoft Windows
================================

There are several alternatives for building the system on Microsoft
Windows:

   a) Use the free MSYS/MinGW development environment (Minimalist GNU
      for Windows, www.mingw.org).  Install MinGW and MSYS, then follow
      the instructions above (i.e. "./configure" followed by "make").

   b) Use the free Cygwin development environment
      (http://www.cygwin.com/).  Install Cygwin, then follow the
      instructions above (i.e. "./configure" followed by "make").

   c) Use the Open Watcom compiler which can be obtained at no charge
      from http://openwatcom.mirrors.pair.com/.  You must perform a
      full installation of the Open Watcom compiler in C:\WATCOM.  From
      the shell, execute the batch file "misc\openwatcom.bat".

   d) Use the Microsoft Visual C++ 2005 Express Edition which can be
      obtained at no charge from Microsoft at this URL:
      http://msdn.microsoft.com/vstudio/express/downloads/default.aspx .
      You must also install the Microsoft Platform SDK.  From the
      shell, execute the batch file "misc\vcexpress.bat".

   e) Use Microsoft Visual Studio .NET 2003.  You must unzip
      "misc\vstudio.zip" in the Gambit distribution's root directory.
      Then with Microsoft Visual Studio open "gambc.sln" and select
      "Build Solution" (Ctrl+Shift+B).

I'm sure that option "e" is not working (because I recently added some  
source files to the Gambit runtime and did not update vstudio.zip).   
So your project file may come in handy.

> Best regards,
> Nick.
>
> ps: What is six.exe and how to build it?

You can build six.exe with:

    copy gsi.exe six.exe

(i.e. six.exe is merely the Gambit interpreter under a different name).

When you start six.exe the interpreter will use the "Scheme infix  
syntax" by default.  To revert to the prefix syntax you must prefix  
the expression with a backslash (instead of the other way around).   
This syntax is based on the C/Java syntax so it makes the Gambit  
runtime accessible to many programmers who do not know Scheme/Lisp.   
It is also interesting for writing compact arithmetic expressions, and  
for writing compact for loops (for scripts, etc).  Here's an example:

Gambit v4.1.2

 > 1+expt(10,40)*5;
50000000000000000000000000000000000000001
 > for (int i=1; i<=4; i++) display([i," ",i*i,"\n"]);
1 1
2 4
3 9
4 16
 > int f(int x) { return expt(2,x)/x; }
 > f(3);
8/3
 > append([1,2,3],[4,5,6]);
(1 2 3 4 5 6)
 > map(int (int x) { return x*x; },[1,2,3]);
(1 4 9)
 >
 > map(\(lambda (x) (* x x)),[1,2,3]);
(1 4 9)

Note that any file with a ".six" extension will be parsed using the  
Scheme infix syntax, so you can write scripts containing only SIX code.

Marc




More information about the Gambit-list mailing list