caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Building a camlp4 toplevel with oasis/ocamlbuild
@ 2012-03-19 18:40 Andre Nathan
  2012-03-19 20:45 ` Jérémie Dimino
  0 siblings, 1 reply; 3+ messages in thread
From: Andre Nathan @ 2012-03-19 18:40 UTC (permalink / raw)
  To: caml-list

Hello

I'm trying to convert my ospec library
(https://github.com/andrenth/ospec) to oasis, so far without success.

Currently I build the camlp4-enabled toplevel with these commands:

ocamlfind ocamlc -dtypes -syntax camlp4o \
    -package camlp4.extend,camlp4.quotations -c pa_spec.ml
ocamlfind ocamlc -dtypes -c spec.mli
ocamlfind ocamlc -dtypes -c spec.ml
ocamlfind ocamlc -dtypes -c report.mli
ocamlfind ocamlc -dtypes -c report.ml
ocamlfind ocamlc -dtypes -c helpers.ml
ocamlfind ocamlc -dtypes -c gen.ml
ocamlfind ocamlc -dtypes -c prop.mli
ocamlfind ocamlc -dtypes -c prop.ml
ocamlfind ocamlc -dtypes -o ospec dynlink.cma -I +camlp4 \
    -package findlib toplevellib.cma camlp4o.cma str.cma \
    spec.cmo report.cmo helpers.cmo gen.cmo prop.cmo \
    pa_spec.cmo ospec.ml -linkpkg \
    -pp "camlp4o Camlp4MacroParser.cmo"

So far what I have for the conversion is this:

_oasis file:

Library ospec
  Path:             .
  BuildTools:       ocamlbuild
  CompiledObject:   byte
  Modules:          Helpers, Prop, Spec, Gen, Pa_spec, Report

Executable ospec
  Path:             .
  BuildTools:       ocamlbuild
  MainIs:           ospec.ml
  CompiledObject:   byte
  BuildDepends:     ospec

_tags file:

"ospec.byte": use_ospec
"ospec.byte": use_toplevel
"ospec.byte": use_dynlink
"ospec.byte": use_camlp4
"ospec.byte": pkg_findlib
"ospec.byte": pkg_str
<ospec.ml>: use_ospec
<ospec.ml>: pkg_findlib
<ospec.ml>: syntax_camlp4o, pkg_camlp4.macro
<pa_spec.ml>: pkg_camlp4.quotations.o
<pa_spec.ml>: pkg_camlp4.extend
<pa_spec.ml>: syntax_camlp4o, pkg_camlp4.extend, pkg_camlp4.quotations

myocamlbuild.ml file:

flag ["file:ospec.byte"]
  (S[A"dynlink.cma"; A"toplevellib.cma"; A"camlp4o.cma"]);

With this configuration I can get the library to compile, but when I try
to execute the toplevel I get this:

$ ./ospec.byte                          
Fatal error: exception Symtable.Error("Printexc")

Can anyone give me a hand here?

Thanks in advance,
Andre


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

* Re: [Caml-list] Building a camlp4 toplevel with oasis/ocamlbuild
  2012-03-19 18:40 [Caml-list] Building a camlp4 toplevel with oasis/ocamlbuild Andre Nathan
@ 2012-03-19 20:45 ` Jérémie Dimino
  2012-03-20 14:11   ` Andre Nathan
  0 siblings, 1 reply; 3+ messages in thread
From: Jérémie Dimino @ 2012-03-19 20:45 UTC (permalink / raw)
  To: Andre Nathan; +Cc: caml-list

Le Mon, 19 Mar 2012 15:40:40 -0300,
Andre Nathan <andre@digirati.com.br> a écrit :

> $ ./ospec.byte                          
> Fatal error: exception Symtable.Error("Printexc")
> 
> Can anyone give me a hand here?

It is because ospec has not be linked with the Printexc module. Since
you define a library "ospec" and you use it for the executable "ospec",
it will be linked against "ospec.cma", and not all the .cmo as you did
before. OCaml remove unused units from ".cma" files passed on the
command line when linking, it only keeps units reachable from
".cmo" files. Printexc has been removed because it was not used. To
prevent this behavior you must pass the "-linkall" switch (note that
you should always use it when you use dynlink).

Cheers,

-- 
Jérémie


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

* Re: [Caml-list] Building a camlp4 toplevel with oasis/ocamlbuild
  2012-03-19 20:45 ` Jérémie Dimino
@ 2012-03-20 14:11   ` Andre Nathan
  0 siblings, 0 replies; 3+ messages in thread
From: Andre Nathan @ 2012-03-20 14:11 UTC (permalink / raw)
  To: Jérémie Dimino; +Cc: caml-list

Thanks a lot.

On Mon, 2012-03-19 at 21:45 +0100, Jérémie Dimino wrote:
> Le Mon, 19 Mar 2012 15:40:40 -0300,
> Andre Nathan <andre@digirati.com.br> a écrit :
> 
> > $ ./ospec.byte                          
> > Fatal error: exception Symtable.Error("Printexc")
> > 
> > Can anyone give me a hand here?
> 
> It is because ospec has not be linked with the Printexc module. Since
> you define a library "ospec" and you use it for the executable "ospec",
> it will be linked against "ospec.cma", and not all the .cmo as you did
> before. OCaml remove unused units from ".cma" files passed on the
> command line when linking, it only keeps units reachable from
> ".cmo" files. Printexc has been removed because it was not used. To
> prevent this behavior you must pass the "-linkall" switch (note that
> you should always use it when you use dynlink).
> 
> Cheers,
> 



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

end of thread, other threads:[~2012-03-20 14:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-19 18:40 [Caml-list] Building a camlp4 toplevel with oasis/ocamlbuild Andre Nathan
2012-03-19 20:45 ` Jérémie Dimino
2012-03-20 14:11   ` Andre Nathan

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