Version française
Home     About     Download     Resources     Contact us    
Browse thread
Statically linking with C object files by bootstrap ocamlc under Cygwin.
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Dmitri Boulytchev <db@t...>
Subject: Statically linking with C object files by bootstrap ocamlc under Cygwin.
    Hello,

    just curious: why can't I produce mixed ocaml+c executable using 
bootstrap compiler?
    File test.ml:

      external cstring: unit -> string = "cstring";;
      Printf.printf "%s\n" (cstring ())

    File testc.c:

      #include <ctype.h>
      #include <mlvalues.h>
      #include <alloc.h> 
      #include <memory.h>
      #include <fail.h>
      #include <string.h>

      CAMLprim value cstring()
     {
       CAMLparam0();
       CAMLlocal1(res);
       char * q;

       res = alloc_string(7);
       q = String_val(res);

       strcpy (q, "Hello!");
       CAMLreturn(res);
    }

    $ gcc -I ../byterun -c testc.c
    $ ../boot/ocamlrun.exe ../boot/ocamlc -nostdlib -I ../boot -custom 
-o test testc.o test.ml
    ../boot/libcamlrun.a(unix.o):unix.c:(.text+0x465): undefined 
reference to `_flexdll_dlopen'
    ../boot/libcamlrun.a(unix.o):unix.c:(.text+0x478): undefined 
reference to `_flexdll_dlclose'
    ../boot/libcamlrun.a(unix.o):unix.c:(.text+0x492): undefined 
reference to `_flexdll_dlsym'
    ../boot/libcamlrun.a(unix.o):unix.c:(.text+0x4ae): undefined 
reference to `_flexdll_dlopen'
    ../boot/libcamlrun.a(unix.o):unix.c:(.text+0x4bd): undefined 
reference to `_flexdll_dlsym'
    ../boot/libcamlrun.a(unix.o):unix.c:(.text+0x4ca): undefined 
reference to `_flexdll_dlerror'
   collect2: ld returned 1 exit status
   File "test.ml", line 1, characters 0-1:
   Error: Error while building custom runtime system

   $ ../boot/ocamlrun.exe ../ocamlc -nostdlib -I ../boot -custom -o test 
testc.o test.ml
   $ ./test
   Hello!

   What do I do wrong?

   Best regards,
   Dmitri Boulytchev,
   St.Petersburg State University.