From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.1 required=5.0 tests=AWL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 105CABB84 for ; Wed, 26 Nov 2008 15:22:15 +0100 (CET) X-IronPort-AV: E=Sophos;i="4.33,669,1220220000"; d="scan'208";a="31863061" Received: from discorde.inria.fr ([192.93.2.38]) by mail4-smtp-sop.national.inria.fr with ESMTP; 26 Nov 2008 15:22:15 +0100 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id mAQEMEkI018419 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Wed, 26 Nov 2008 15:22:14 +0100 X-IronPort-AV: E=Sophos;i="4.33,669,1220220000"; d="scan'208";a="17642491" Received: from unknown (HELO [10.204.1.211]) ([194.199.1.33]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 26 Nov 2008 15:22:14 +0100 Message-ID: <492D5B8D.8050404@sophia.inria.fr> Date: Wed, 26 Nov 2008 15:22:05 +0100 From: Yves Bertot User-Agent: Thunderbird 1.5.0.10 (Macintosh/20070221) MIME-Version: 1.0 To: caml-list@inria.fr Subject: Tutorial example for nat dynlink Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Miltered: at discorde with ID 492D5B96.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; nat:01 dynlink:01 dynlink:01 mli:01 val:01 loadfile:01 ocamlopt:01 native-code:01 compiler:01 lib:01 ocaml:01 ocamlopt:01 mli:01 -shared:01 cmxa:01 Hello, I have been trying to build a small example "hello world" program using native dynlink, but I don't manage to make it work. Could please send me some advice? Here are my programs: -------- toto.mli ---- val ff : (unit -> unit) ref;; -------- toto.ml ----- Dynlink.init();; let ff = ref (fun () -> ());; try Dynlink.loadfile "bidon.cmxs" with Dynlink.Error(e) -> print_string (Dynlink.error_message e ^ "\n");; !ff();; ------ bidon.ml ----- let hello () = print_string "hello world!\n";; Toto.ff := hello;; ------ end of files ------ ocamlopt -v returns The Objective Caml native-code compiler, version 3.11.0+beta1 Standard library directory: .../lib/ocaml And I compile my files in the following manner. ocamlopt toto.mli ocamlopt -shared -o bidon.cmxs bidon.ml ocamlopt -o toto dynlink.cmxa toto.ml My test runs as follows, with a behavior I did not expect: ./toto no implementation available for Toto Can you tell me what is missing in my experiment, or point me to an example that would be about the same size? Yves