Miscellaneous Esterel Resources

This page contains three sections:

Installing Win32 build tools for Esterel

A compiler is required in order to process the C output of the esterel compiler. Additionally, a linker and several library files are required by the xes simulator. These components are available without charge for the Win32 environment but, unfortunately, not as a single package.

The Visual C++ Toolkit 2003 includes a compiler, cl.exe, and linker, link.exe. To install:

  1. Download the installer from http://msdn.microsoft.com/visualc/vctoolkit2003
  2. Run VCToolkitSetup.exe, and work through the Installer wizard.
  3. By default the binaries are installed to c:\Program Files\Microsoft Visual C++ Toolkit 2003\bin. This directory should be added to the system path:
    1. Open the control panel
    2. Open the System icon
    3. Choose the Advanced tab
    4. Click on Environment Variables...
    5. Find and edit the Path variable (adding, for example: "c:\Program Files\Microsoft Visual C++ Toolkit 2003\bin")

Being able to run cl.exe and link.exe from a command shell is requisite for compiling and simulating Esterel programs.

It may well be possible to use another C compiler and linker. In this case, the xesterel options (Options/General Preferences.../C Compiler) should be updated, as should the xes.def file (...\Esterel\lib\xes\xes.def, line 29). This author has made no such attempt.

xes requires several static (mostly not dynamic) libraries in order to link and simulate a compiled Esterel program: advapi32.dll, user32.lib, gdi32.lib, comdlg32.lib, winspool.lib, and msvcrt.lib. All but the last are available within the Microsoft Windows Platform SDK which one can download without charge. The version required is the Windows ServerⓇ 2003 SP1 Platform SDK Web Install for i386, PSDK-x86.exe. Only a single component need be installed: Microsoft Windows Core SDK/Build Environment/Build Environment (x86 32-bit). By default the required files are installed to c:\Program Files\Microsoft Platform SDK\Lib

To acquire msvcrt.lib one should download and install both the .NET Framework Redistributable Package version 2.0 and the .NET Framework 2.0 Software Development Kit (both in Beta 1 version at the time of writing). They are available for download without charge. By default the required file is installed to c:\Program Files\Microsoft Visual Studio 8\VC\lib.

After installing both packages, the required files should either be copied into the same directory as the Esterel object file (*.obj) to be simulated, or the relevant paths should be added to the LIB environment variable.

Fixing Esterel v5.92 __ctype_b problems

The Esterel v5.92 tools are old but still quite useful. Unfortunately the xes binary no longer functions with recent releases of the GNU C library. This page presents a possible solution that does not require any recompilation (which would otherwise be ideal if the source code were available).

The problem

Running xes results in errors:

### --- Linking ... 
### cc -o /tmp/xes10240364203113.exe backhoe_sim.o
/opt/esterelv5_92.linux/lib/libxes.a
/opt/esterelv5_92.linux/tcltk/lib/libtk8.2.a
/opt/esterelv5_92.linux/tcltk/lib/libtcl8.2.a -L/usr/X11R6/lib -lX11 -ldl
-lm
*** /opt/esterelv5_92.linux/tcltk/lib/libtcl8.2.a(tclUnixPipe.o): In
function `TclpCreateTempFile':
tclUnixPipe.c:(.text+0xf0): warning: the use of `tmpnam' is dangerous,
better use `mkstemp'
/opt/esterelv5_92.linux/lib/libxes.a(client.o): In function `_XesRecord':
client.c:(.text+0x4e): undefined reference to `__ctype_b'
/opt/esterelv5_92.linux/tcltk/lib/libtk8.2.a(tkGet.o): In function
`Tk_GetScreenMM':
tkGet.c:(.text+0x7dd): undefined reference to `__ctype_b'
tkGet.c:(.text+0x87e): undefined reference to `__ctype_b'
/opt/esterelv5_92.linux/tcltk/lib/libtk8.2.a(tkGet.o): In function
`Tk_GetPixels':
tkGet.c:(.text+0x92f): undefined reference to `__ctype_b'
tkGet.c:(.text+0xa20): undefined reference to `__ctype_b'
/opt/esterelv5_92.linux/tcltk/lib/libtk8.2.a(tkOption.o):tkOption.c:(.text+0x197):
more undefined references to `__ctype_b' follow
collect2: ld returned 1 exit status
make: *** [backhoe_sim.exe] Error 1

A solution

Either, simply replace the libtk8.2.a that is disributed with the Esterel compiler with this version (md5: 6d80f00d140310f80ad3340d8837b3e6), or build your own using the following instructions.

Add the __ctype_b data (and dependencies) into the Tk archive—the one distributed with the Esterel compiler—so that it is available when code is linked into a simulator binary by xes.

  1. Acquire a libc.a file from an earlier version of glibc-devel. Version 2.1.2 was contemporaneous with Tcl/Tk 8.2.3:
    1. Download glibc-devel-2.1.2-11.i386.rpm
    2. Extract usr/libc:
      mkdir -p usr/lib
      rpm2cpio glibc-devel-2.1.2-11.i386.rpm | cpio -i usr/lib/libc.a
      mv usr/lib/libc.a .
      rmdir -p lib/usr
      
  2. Extract three required object files:
    ar x libc.a ctype-info.o C-ctype.o C_name.o
    
  3. Add them to libtk8.2.a:
    ar q $(ESTEREL_HOME)/tcltk/lib/libtk8.2.a C-ctype.o C_name.o ctype-info.o 
    

Why not just recompile Tcl/Tk?

libxes.a also requires the older ctype data structure:

### --- Linking ... 
### cc -o /tmp/xes11063364203545.exe backhoe_sim.o
/opt/esterelv5_92.linux/lib/libxes.a
/opt/esterelv5_92.linux/tcltk/lib/libtk8.2.a
/opt/esterelv5_92.linux/tcltk/lib/libtcl8.2.a -L/usr/X11R6/lib -lX11 -ldl
-lm
*** /opt/esterelv5_92.linux/tcltk/lib/libtcl8.2.a(tclUnixPipe.o): In
function `TclpCreateTempFile':
tclUnixPipe.c:(.text+0xd7): warning: the use of `tmpnam' is dangerous,
better use `mkstemp'
/opt/esterelv5_92.linux/lib/libxes.a(client.o): In function `_XesRecord':
client.c:(.text+0x4e): undefined reference to `__ctype_b'
collect2: ld returned 1 exit status
make: *** [backhoe_sim.exe] Error 1

Although Tcl/Tk 8.2.3 does still compile after some minor patching:

  1. Download:
    • Tk 8.2 sources (tk8.2.3.tar.gz)
    • Tcl 8.2 sources (tcl8.2.3.tar.gz)
  2. Extract both tarballs into the same directory.
  3. Apply the patch (patch -p0 < tcl+tk-8.2.3.patch).
  4. cd tcl8.2.3/unix
  5. ./configure --disable-shared
  6. make
  7. cd tk8.2.3/unix
  8. ./configure --disable-shared
  9. make
  10. cp tcl8.2.3/unix/libtcl8.2.a $ESTEREL_HOME/tcltk/lib/libtcl8.2.a
  11. cp tk8.2.3/unix/libtk8.2.a $ESTEREL_HOME/tcltk/lib/libtk8.2.a

Printing with a2ps

This style sheet enables a2ps to pretty print Esterel programs, it is based on version 5.92 of the Esterel primer. To install:

  • for a single user:
    1. Save the style sheet in $HOME/.a2ps
    2. If necessary, create a sheets.map file in the same directory.
    3. Add a line to the file: esterel: /*.strl/
  • for an entire system:
    1. Save the style sheet in the sheets subdirectory of the a2ps system directory (e.g. /usr/local/share/a2ps).
    2. Add a line to the sheets.map file in the same directory: esterel: /*.strl/