[MLton-user] Linking issues with FFI on Vista

John Reppy t-johrep at microsoft.com
Mon Sep 8 05:29:18 PDT 2008


I have the following SML code for handling the display callback in GLUT:

    val exportDisplay           = _export "glutDisplayCB" stdcall : (unit -> unit) -> unit;
    val glutDisplayCB           = _address "glutDisplayCB" : Ptr.t;
    val glutDisplayFunc         = _import "glutDisplayFunc" stdcall : Ptr.t -> unit;
    fun displayFunc (SOME f) = (
          exportDisplay f;
          glutDisplayFunc glutDisplayCB)
      | displayFunc NONE = glutDisplayFunc Ptr.null

When I compile and link this code on Vista (using MinGW), I get

    C:\Users\t-johrep\AppData\Local\Temp\fileQXimuh.o:main.0.S:(.text+0x1a95): undefined reference to `_imp__glutDisplayCB'

The source of this error is code generated by MLton:

    $ grep glutDisplayCB main*
    main.0.S:       movl (__imp__glutDisplayCB+0x0),%ebp
    main.3.c:EXPORTED void __attribute__ ((stdcall)) glutDisplayCB () {

This code builds and runs fine on Linux and Mac OS X.

        - John




More information about the MLton-user mailing list