Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
C-Interface problem
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2001-02-12 (13:04)
From: wester@i...
Subject: C-Interface problem

I want to write a small extension to OCaml (my first try).

I have the following files:

external ilt_spawn : string -> string -> int = "ilt_spawn"
open Primitives
let sp = ilt_spawn

I type:
ocamlc -c primitives.mli

and get primitives.cmi.

When I then try to compile with

ocamlc -c

I get the error message:

The implementation does not match the interface
primitives.cmi: The field 'ilt_spawn' is required but not provided. 

What did I do wrong?

My primitives.c file reads:

#include <caml/mlvalues.h>
#include <process.h>
extern "C"
 int ilt_spawn_(const char * cmd, const char * argument)
  int ret = _spawnl(_P_NOWAIT, cmd, cmd, argument, NULL);
  return ret;
 value ilt_spawn(value cmd, value argument)
  int ret = ilt_spawn_((const char * ) String_val(cmd), (const char *
  )String_val(argument)); return Val_long(ret);

I compile this file with VC++6.0. I would like to build a toplevel with:

ocamlmktop -custom -o mytop primitives.obj primitives.cma

Would this be correct?

I would be very appreciative for help on this problem.

With kind regards.

Rolf Wester

Rolf Wester