caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Kamil Shakirov" <kamils@inbox.ru>
To: <caml-list@inria.fr>, <onlynews@metaprl.org>
Subject: Re: [Caml-list] Compiling a native code OCaml library into an .so?
Date: Thu, 20 Nov 2003 06:33:37 +0300	[thread overview]
Message-ID: <004001c3af17$20b46df0$dd79b1d5@tornado> (raw)
In-Reply-To: <3FBC0177.1050307@cs.caltech.edu>

Hello,

> I am wondering - is it possible to compile a native code OCaml library 
> into an dynamic library (.so) and then link an OCaml program against it, 
> or dynamically load it from an OCaml program?
> 
> My (very shallow) understanding of how this is supposed to work suggests 
> that it should not be too hard to implement (at least if we do not 
> insist on detecting version mismatches at runtime). We would need:
> 
> 1) A flag to ocamlopt that would tell it to compile to ".cmxa + .so" 
> instead of ".cmxa + .a". Given such a flag, ocamlopt would
>    a) Create an assembly file defining _init function that would call 
> the initialization functions of all the modules and add that file to the 
> list of things to be compiled in.
>    b) Add -shared flag to the ld call.
> 
> 2) When compiling a program with ocamlopt, if one of the arguments is a 
> .cmxa, then look for both .a and .so and pass the right one to ld.
> 
> 3) Have a function somewhere (Dynlink module?) that's a wrapper for the 
> C's dlopen function.
> 
> 4) Ideally - have a function somewhere (Dynlink module?) that would try 
> loading a .cma when running in bytecode and would try loading an .so 
> when running in native code.
> 
> Am I missing any serious difficulties here? Are there any plans to add 
> something like this to OCaml?

Look at the http://www.boblycat.org/~malc/scaml/

--
 Kamil.

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


  reply	other threads:[~2003-11-20  3:30 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-11-19 23:49 Aleksey Nogin
2003-11-20  3:33 ` Kamil Shakirov [this message]
2003-11-20  4:57   ` Aleksey Nogin
2003-11-20 11:13   ` [Caml-list] Caml as C-- (was: Compiling a native code OCaml library into an .so?) Oleg Trott
2003-11-20 11:30     ` Ville-Pertti Keinonen
2003-11-20 17:07       ` Oleg Trott
2003-11-20 11:46     ` Christian Lindig
2003-11-20 11:45       ` [Caml-list] Caml as C-- ZHAO Wei
2003-11-20 16:37       ` [Caml-list] Caml as C-- (was: Compiling a native code OCaml library into an .so?) Oleg Trott

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='004001c3af17$20b46df0$dd79b1d5@tornado' \
    --to=kamils@inbox.ru \
    --cc=caml-list@inria.fr \
    --cc=onlynews@metaprl.org \
    /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).