Hardcore Processing - Realize Your Wild Software Ideas Affordably

MLTON FOR WINDOWS


Start Here | News | For Artists | For Developers | Products & Projects | Research & Articles | Entertainment | Company Profile | Contact

Introduction

This document decribes how to install the Linux to Windows cross-compiler version of the Standard ML compiler MLton. Thanks a lot to Stephen T. Weeks and the other people of the MLton project for lots of help with this!

It is the latest attempt at porting version 20010806 of MLton - but it is not complete yet.

Installing the cross-compiler

First of all you need to install the following:

  1. The SML/NJ compiler. I recommend SML/NJ version 110.0.7 but see the last section of this document for details.
  2. A native gcc compiler for Linux.
  3. The Mingw32 cross-compiler version of gcc.
  4. My WinMain library. Currently libmlton.h expects winmain.h to be in /usr/local/devtools/C_CPP/WinMain/srcC/ - but you can modify libmlton.h.
  5. And optionally Sam Lantinga's SDL library if you need to use that. Currently libmlton.h expects the SDL headers to be in /usr/local/cross-tools/i386-mingw32msvc/include/SDL/ when cross compiling and in /usr/include/SDL/ for native compilation - but you can modify libmlton.h.

To download and install the MLton crosscompiler, do the following:

  1. Download MLton_ANOQ20020201.tar.gz
  2. Unpack with these commands:
    gzip -d MLton_ANOQ20020201.tar.gz
    tar -xvf MLton_ANOQ20020201.tar
    
  3. Make a second copy of the upacked directory with this command:
    cp -r MLton_ANOQ20020201/ MLton_ANOQ20020201_ToWin32
    
  4. Install a native Linux version of MLton - if you haven't already got one. The lastest binary distribution from the homepage of MLton should do.
  5. Now compile this new Linux native version of MLton with these commands:
    cd MLton_ANOQ20020201/src
    make
    make install
    cd ../..
    
    This will make sure that you have the right include files with conditional Win32 modifications on your system.
  6. Execute these commands:
    cd MLton_ANOQ20020201_ToWin32/src
    make target=win32
    make install target=win32
    

Constants file

One thing which doesn't work yet is generation of correct program constants files during the cross-compiler bootstrap process. Generating a new constants file for Linux is done like this:

make -stop constprog

Generating a new constants file for Windows:

make target=win32 -stop constprog
cp mlton/mlton_constProg /mnt/somewindowsdirectory/mlton_constProg.exe
C:\somewindowsdirectory\mlton_constProg mlton.const
cp /mnt/somewindowsmachine/mlton.const mlton/

Notice that 'mlton_constProg' is a Windows binary which must be executed on a Windows machine!

Here is a document which describes the MLton bootstrap process for Win32:

Brand new compiler flags for MLton

This brand new MLton crosscompiler some brand new compiler flag that you can set.

To compile ordinary Win32 applications you should problably set the flags something like this:

-D_WIN32 -L/usr/local/cross-tools/lib -L<WhereeverItIsInstalled>/WinMain/srcC/ -lmingw32 -lwinmain -luser32 -lgdi32 -lwinmm -ldxguid

To compile SDL applications you should problably set the flags something like this (besides linking with SDLFuncs.o from SDL::ML):

-D_WIN32 -DUSE_SDL -L/usr/local/cross-tools/lib -lmingw32 -lSDLmain -lSDL -luser32 -lgdi32 -lwinmm -ldxguid -mwindows
Now you might want to check out how to use my SDL bindings for ML - SDL::ML.

A note for using MLton's cmcat and MLKit at the same time

To use MLTon's cmcat tool (for concatenating an SML/NJ/CM project into one single sourcefile suitable for compilation with MLton) you will also need SML/NJ working version 110.9.1 or later. Notice that this may conflict if you're also using MLKit for typechecking your code, since MLKit does NOT compile with SML/NJ version 110.9.1, where as SML/NJ version 110.0.3 and SML/NJ version 110.0.7 works fine for MLKit. And to run either MLKit or cmcat you need an SML/NJ runtime of a compatible version, so you may soon find yourself continuously swapping between 2 versions of SML/NJ.

However if you change line 153 of the cmcat source code from '[file] => ((cmcat{sources = mkAbsolute{path =file, relativeTo = getDir()}' to '[file] => ((cmcat{sources = mkAbsolute (file, getDir())'

It should compile with SML/NJ version 110.0.7 so that you can use the same runtime for both MLKit and cmcat.

Older release based on MLton 19990712

Follow the link below for an older release of MLton which is based on the '1999-7-12' release of MLton.





Hardcore ProcessingModified: 2023-05-19
E-mail: Contact