caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Pierre-Loïc Garoche" <Pierre-Loic.Garoche@onera.fr>
To: Alain Frisch <alain@frisch.fr>, Julien Signoles <julien.signoles@cea.fr>
Cc: "Pierre-Loïc Garoche" <Pierre-Loic.Garoche@onera.fr>,
	caml-list@yquem.inria.fr, thirioux@enseeiht.fr
Subject: Re: [Caml-list] Dynamic loading of native code : what about librairies and packs ?
Date: Tue, 1 Sep 2009 10:56:47 +0200	[thread overview]
Message-ID: <20090901085647.GF4549@onera.fr> (raw)
In-Reply-To: <49D24603.7060509@frisch.fr>

[-- Attachment #1: Type: text/plain, Size: 1814 bytes --]

Hi Alain, Julien and all other Ocaml list members,

I am still having some problems with the dynamic loading of native code. Allow me to give you an extremely simple example to illustrate my problem. I hope you can clarify my understanding of it.

My problem concerns the dynamic loading of native code where the dynamic code loaded depends on another library.

Basically there are three files: 
- main.ml, dynamically loading the plugin
- plugin.ml, the loaded code that depends on the external lib
- mylib.ml, the external lib

///////
main.ml:
let _ = print_string "main\n"
let _ = Dynlink.loadfile "MyPlugin.cmxs"

compiled with ocamlopt -o MyProg dynlink.cmxa main.ml

///////
mylib.ml:
let _ = print_string "mylib\n"
let myval : (int , int) Hashtbl.t = Hashtbl.create 13

compiled with ocamlopt -a -linkall -o mylib.cmxa mylib.ml

//////
plugin.ml:
let _ = print_string "plugin\n"
let cst = Mylib.myval

compiled and linked to build a shared library with
ocamlopt -shared -linkall -o MyPlugin.cmxs mylib.cmxa plugin.ml

Running it gives me the following error
error loading shared library: blabla/MyPlugin.cmxs: undefined symbol: camlHashtbl__create_79


Remark1 : Of course, building a standalone plugin works:
ocamlopt -o PluginSelf mylib.cmxa plugin.cmx

Remark2: If I don't rely on an external module and replace myval by an integer or any other self defined type value, it works as well.

Remark3: The linkall option does not seems to have an impact on such simple example.


Question: How should I link it to rely on external libraries and produce a valid MyPlugin.cmxs ?

Any hint or comment will be greatly appreciated !

Best regards,

pl


-- 
Pierre-Loïc Garoche
pierre-loic.garoche@onera.fr
http://www.onera.fr/staff/pierre-loic-garoche/

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

  parent reply	other threads:[~2009-09-01  8:55 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-31 16:24 Pierre-Loïc Garoche
2009-03-31 16:34 ` [Caml-list] " Alain Frisch
2009-03-31 16:38   ` Pierre-Loïc Garoche
2009-03-31 17:14     ` Alain Frisch
2009-09-01  8:56   ` Pierre-Loïc Garoche [this message]
2009-09-01  9:13     ` Christophe TROESTLER
2009-09-01 10:01     ` Alain Frisch
2009-04-01  9:02 ` Julien Signoles

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=20090901085647.GF4549@onera.fr \
    --to=pierre-loic.garoche@onera.fr \
    --cc=alain@frisch.fr \
    --cc=caml-list@yquem.inria.fr \
    --cc=julien.signoles@cea.fr \
    --cc=thirioux@enseeiht.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).