caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Dynamic module loading
@ 2001-11-10 23:27 Dimitri Timofeev
  2001-11-11  0:15 ` Michael Hicks
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Dimitri Timofeev @ 2001-11-10 23:27 UTC (permalink / raw)
  To: OCaml mailing list

Greetings!

I'm a newbie in OCaml programming and in this list, so i'm sorry if my
questions aren't smart :).

Can i dynamically load OCaml bytecode modules in runtime from OCaml
program compiled to native code? Can i do it if i compile modules to
native code? If the answer is "yes", does the method work at Win32?

If i can't use native-compiled modules only, there is another question.
That is the minimal set of OCaml files i need to distribute with a
program if i want users to be able to run program compiled to bytecode
without installing OCaml itself?

Thanks!

Dimitri


-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


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

* RE: [Caml-list] Dynamic module loading
  2001-11-10 23:27 [Caml-list] Dynamic module loading Dimitri Timofeev
@ 2001-11-11  0:15 ` Michael Hicks
  2001-11-11 22:09   ` Vitaly Lugovsky
  2001-11-11  1:00 ` malc
  2001-11-11 16:45 ` Xavier Leroy
  2 siblings, 1 reply; 7+ messages in thread
From: Michael Hicks @ 2001-11-11  0:15 UTC (permalink / raw)
  To: Dimitri Timofeev, OCaml mailing list

Fabrice's asmdynlink library allows loading bytecode modules from
compiled-to-native executables, but at a performance cost relative to normal
bytecode interpration times. Bytecode executables can load bytecode modules
using the standard Dynlink library.  Asmdynlink os distributed with the CDK
(http://pauillac.inria.fr/cdk/).

Mike

> -----Original Message-----
> From: owner-caml-list@pauillac.inria.fr
> [mailto:owner-caml-list@pauillac.inria.fr]On Behalf Of Dimitri Timofeev
> Sent: Saturday, November 10, 2001 6:27 PM
> To: OCaml mailing list
> Subject: [Caml-list] Dynamic module loading
>
>
> Greetings!
>
> I'm a newbie in OCaml programming and in this list, so i'm sorry if my
> questions aren't smart :).
>
> Can i dynamically load OCaml bytecode modules in runtime from OCaml
> program compiled to native code? Can i do it if i compile modules to
> native code? If the answer is "yes", does the method work at Win32?
>
> If i can't use native-compiled modules only, there is another question.
> That is the minimal set of OCaml files i need to distribute with a
> program if i want users to be able to run program compiled to bytecode
> without installing OCaml itself?
>
> Thanks!
>
> Dimitri
>
>
> -------------------
> Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ:
http://caml.inria.fr/FAQ/
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/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


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

* Re: [Caml-list] Dynamic module loading
  2001-11-10 23:27 [Caml-list] Dynamic module loading Dimitri Timofeev
  2001-11-11  0:15 ` Michael Hicks
@ 2001-11-11  1:00 ` malc
  2001-11-11 16:45 ` Xavier Leroy
  2 siblings, 0 replies; 7+ messages in thread
From: malc @ 2001-11-11  1:00 UTC (permalink / raw)
  To: Dimitri Timofeev; +Cc: OCaml mailing list

On Sat, 10 Nov 2001, Dimitri Timofeev wrote:

> Greetings!
> 
> I'm a newbie in OCaml programming and in this list, so i'm sorry if my
> questions aren't smart :).
> 
> Can i dynamically load OCaml bytecode modules in runtime from OCaml
> program compiled to native code? Can i do it if i compile modules to
> native code? If the answer is "yes", does the method work at Win32?
Yes(More detailed answer on this one is in Michael Hicks's post). Yes. No.

-- 
mailto:malc@pulsesoft.com

-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


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

* Re: [Caml-list] Dynamic module loading
  2001-11-10 23:27 [Caml-list] Dynamic module loading Dimitri Timofeev
  2001-11-11  0:15 ` Michael Hicks
  2001-11-11  1:00 ` malc
@ 2001-11-11 16:45 ` Xavier Leroy
  2 siblings, 0 replies; 7+ messages in thread
From: Xavier Leroy @ 2001-11-11 16:45 UTC (permalink / raw)
  To: Dimitri Timofeev; +Cc: OCaml mailing list

Your first question was answered, so let me address the second one:

> If i can't use native-compiled modules only, there is another question.
> That is the minimal set of OCaml files i need to distribute with a
> program if i want users to be able to run program compiled to bytecode
> without installing OCaml itself?

No additional files are needed if you perform the final link with
"ocamlc -custom".  This will create a stand-alone executable
incorporating the OCaml bytecode interpreter, runtime system, and the
bytecode for your program.

Correction: the OCaml runtime system is a C program, and as such can
require certain DLLs containing the C runtime.  Under Unix, you can
even force static linking of these C runtime libs using
  ocamlc -ccopt -static -custom
Under Windows, no such -static option exists, and you'll have to
ensure the users have the required DLLS (winsock.dll for the pure
Win32 port of OCaml, cygwin1.dll for the Cygwin port).

- Xavier Leroy
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


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

* RE: [Caml-list] Dynamic module loading
  2001-11-11  0:15 ` Michael Hicks
@ 2001-11-11 22:09   ` Vitaly Lugovsky
  2001-11-12 11:22     ` Fabrice Le Fessant
  0 siblings, 1 reply; 7+ messages in thread
From: Vitaly Lugovsky @ 2001-11-11 22:09 UTC (permalink / raw)
  To: Michael Hicks; +Cc: OCaml mailing list

On Sat, 10 Nov 2001, Michael Hicks wrote:

> Fabrice's asmdynlink library allows loading bytecode modules from
> compiled-to-native executables, but at a performance cost relative to normal
> bytecode interpration times. Bytecode executables can load bytecode modules
> using the standard Dynlink library.  Asmdynlink os distributed with the CDK
> (http://pauillac.inria.fr/cdk/).

 And what about JIT compiler included there? Is it already usable?
Is there any benchmarks?

-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


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

* RE: [Caml-list] Dynamic module loading
  2001-11-11 22:09   ` Vitaly Lugovsky
@ 2001-11-12 11:22     ` Fabrice Le Fessant
  0 siblings, 0 replies; 7+ messages in thread
From: Fabrice Le Fessant @ 2001-11-12 11:22 UTC (permalink / raw)
  To: Vitaly Lugovsky; +Cc: Michael Hicks, OCaml mailing list


>  On Sat, 10 Nov 2001, Michael Hicks wrote:
>  
>  > Fabrice's asmdynlink library allows loading bytecode modules from
>  > compiled-to-native executables, but at a performance cost relative to normal
>  > bytecode interpration times. Bytecode executables can load bytecode modules
>  > using the standard Dynlink library.  Asmdynlink os distributed with the CDK
>  > (http://pauillac.inria.fr/cdk/).
>  
>   And what about JIT compiler included there? Is it already usable?
>  Is there any benchmarks?

The JIT compiler is still unstable (probably some bugs need to be
fixed). But you can try it by setting OCAMLJIT to true in your
envirronment, before calling a program using asmdynlink ...

- Fabrice
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


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

* [Caml-list] Dynamic module loading
@ 2001-11-12  5:21 Dimitri Timofeev
  0 siblings, 0 replies; 7+ messages in thread
From: Dimitri Timofeev @ 2001-11-12  5:21 UTC (permalink / raw)
  To: OCaml mailing list

Greetings!

Thanks to all for your help! Your answers were very useful for me.

There is another question at the same subject. Can i use LablTk in
dynamically loaded module? I've tried and i've encountered a problem.

I take some code (i.e. eyes.ml) using LablTk. I write an example
that should be able to load modules:

let main () =
    try
        Dynlink.init ();
        Dynlink.add_interfaces ["Pervasives"; "Printexc"; "Tk"; "Frame"]
                               [Sys.getcwd (); "/usr/lib/ocaml";
                                "/usr/lib/ocaml/labltk"];
        Dynlink.loadfile Sys.argv.(1)
    with
    | Dynlink.Error e ->
        print_string "Dynamic linking error: ";
	print_string (Dynlink.error_message e);
	print_newline ()
;;

let _ = main ()
;;

I compile main.ml with command line "ocamlc -o main dynlink.cma main.ml"
and eyes.ml with "ocamlc -c -I +labltk eyes.ml".

Then i try to call it: "./main eyes.cmo", and i get Dynlink.Error
exception saying that there is no implementation available for Support.
But if i try to add "Support" into modules list, i get exception
Not_found. It seems right, because i have no "support.cmi" file.

Do i have some mistakes in my code or command lines, or i'm going a wrong
way?

Thanks again for your help. I'm very glad to be on this list.

Dimitri


-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


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

end of thread, other threads:[~2001-11-12 12:21 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-11-10 23:27 [Caml-list] Dynamic module loading Dimitri Timofeev
2001-11-11  0:15 ` Michael Hicks
2001-11-11 22:09   ` Vitaly Lugovsky
2001-11-12 11:22     ` Fabrice Le Fessant
2001-11-11  1:00 ` malc
2001-11-11 16:45 ` Xavier Leroy
2001-11-12  5:21 Dimitri Timofeev

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