caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Compiling a file using the Toploop module
@ 2012-08-02 23:55 Jean-Baptiste Jeannin
  2012-08-03  0:21 ` Daniel Bünzli
  0 siblings, 1 reply; 3+ messages in thread
From: Jean-Baptiste Jeannin @ 2012-08-02 23:55 UTC (permalink / raw)
  To: caml-list

Hi all,

I have been using the Toploop module in some code that I have always 
interpreted using the "ocaml" command. I am now trying to compile this 
code using "ocamlc", but I keep getting the following error:

File "try_toploop.ml", line 1, characters 0-1:
Error: Error while linking try_toploop.cmo:
Reference to undefined global `Toploop'


More precisely, this error can be reproduced with a file try_toploop.ml 
containing just the two lines:

module T = Toploop;;
print_int 0;;

It interprets fine with the ocaml interpreter (or as a matter of fact, 
in the toplevel system):
$ ocaml try_toploop.ml
0

However, if I try to compile it, I get:
$ ocamlc try_toploop.ml
File "try_toploop.ml", line 1, characters 0-1:
Error: Error while linking try_toploop.cmo:
Reference to undefined global `Toploop'

I am wondering how to compile such a file using ocamlc, or even if it is 
possible. I have been looking for possible options to include a pointer 
to a toploop.cmo, but could not solve the problem. Thank you for your help!

Jean-Baptiste Jeannin

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

* Re: [Caml-list] Compiling a file using the Toploop module
  2012-08-02 23:55 [Caml-list] Compiling a file using the Toploop module Jean-Baptiste Jeannin
@ 2012-08-03  0:21 ` Daniel Bünzli
  2012-08-05 23:41   ` Jean-Baptiste Jeannin
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Bünzli @ 2012-08-03  0:21 UTC (permalink / raw)
  To: Jean-Baptiste Jeannin; +Cc: caml-list



Le vendredi, 3 août 2012 à 01:55, Jean-Baptiste Jeannin a écrit :

> I am wondering how to compile such a file using ocamlc, or even if it is
> possible. I have been looking for possible options to include a pointer  
> to a toploop.cmo, but could not solve the problem. Thank you for your help!

If you are using 4.00 the following invocation works :

ocamlc -I +compiler-libs ocamlcommon.cma ocamlbytecomp.cma ocamltoplevel.cma try_toploop.ml

Best,

Daniel
  


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

* Re: [Caml-list] Compiling a file using the Toploop module
  2012-08-03  0:21 ` Daniel Bünzli
@ 2012-08-05 23:41   ` Jean-Baptiste Jeannin
  0 siblings, 0 replies; 3+ messages in thread
From: Jean-Baptiste Jeannin @ 2012-08-05 23:41 UTC (permalink / raw)
  To: Daniel Bünzli; +Cc: caml-list

> If you are using 4.00 the following invocation works :
>
> ocamlc -I +compiler-libs ocamlcommon.cma ocamlbytecomp.cma ocamltoplevel.cma try_toploop.ml
>
> Best,
>
> Daniel
>    
Thank you for your answer. I am still using 3.12, and in 3.12 the same 
is achieved by:

ocamlc toplevellib.cma try_toploop.ml


Jean-Baptiste

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

end of thread, other threads:[~2012-08-05 23:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-02 23:55 [Caml-list] Compiling a file using the Toploop module Jean-Baptiste Jeannin
2012-08-03  0:21 ` Daniel Bünzli
2012-08-05 23:41   ` Jean-Baptiste Jeannin

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