caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Yves Bertot <Yves.Bertot@sophia.inria.fr>
To: caml-list@inria.fr
Subject: Tutorial example for nat dynlink
Date: Wed, 26 Nov 2008 15:22:05 +0100	[thread overview]
Message-ID: <492D5B8D.8050404@sophia.inria.fr> (raw)

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




             reply	other threads:[~2008-11-26 14:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-26 14:22 Yves Bertot [this message]
2008-11-26 14:34 ` [Caml-list] " Xavier Leroy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=492D5B8D.8050404@sophia.inria.fr \
    --to=yves.bertot@sophia.inria.fr \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).