caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Shared libraries again
@ 2002-09-21 16:54 Dmitry Lomov
  2002-09-21 21:46 ` malc
  0 siblings, 1 reply; 2+ messages in thread
From: Dmitry Lomov @ 2002-09-21 16:54 UTC (permalink / raw)
  To: caml-list

Hi,
is it possible build a shared C library which calls Caml code? It is OK
if shared library uses Caml runtime statically. I do not need to 
call Caml runtime from different shared libraries - only from one,
and it is OK for me if Caml values will be invalid outside shared
library. That is, my shared library wholly controls Caml runtime
startup.
For some reason ocamlmklib does not work for me - when I try to load
library created by it,  various caml_* references cannot be unresolved.

I am on Linux, i386.

Thanks in advance,
Dmitry

-- 
Dmitry Lomov
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

-------------------
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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Caml-list] Shared libraries again
  2002-09-21 16:54 [Caml-list] Shared libraries again Dmitry Lomov
@ 2002-09-21 21:46 ` malc
  0 siblings, 0 replies; 2+ messages in thread
From: malc @ 2002-09-21 21:46 UTC (permalink / raw)
  To: Dmitry Lomov; +Cc: caml-list

On 21 Sep 2002, Dmitry Lomov wrote:

> Hi,
> is it possible build a shared C library which calls Caml code? It is OK
> if shared library uses Caml runtime statically. I do not need to 
> call Caml runtime from different shared libraries - only from one,
> and it is OK for me if Caml values will be invalid outside shared
> library. That is, my shared library wholly controls Caml runtime
> startup.

*** Makefile
main: lib.so sh_c.o
        cc -o $@ $+ -Wl,-rpath,.

lib.so: sh.ml
        ocamlopt -c sh.ml
        ocamlopt -o $@ -cclib -shared sh.cmx

sh_c.o: sh_c.c
        ocamlc -o $@ -c $<

*** sh_c.c
#include <stdio.h>
#include <caml/mlvalues.h>
#include <caml/callback.h>

int main (int argc, char **argv)
{
  caml_startup(argv);
  callback (*caml_named_value ("ml_func"), Val_unit);
  return 0;
}

*** sh.ml
let ml_func () =
  print_string "moo";
  print_newline ()

let _ = Callback.register "ml_func" ml_func

-- 
mailto:malc@pulsesoft.com

-------------------
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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-09-21 21:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-21 16:54 [Caml-list] Shared libraries again Dmitry Lomov
2002-09-21 21:46 ` malc

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).