Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[Caml-list] How to compile using sexplib?

21 views
Skip to first unread message

Luca de Alfaro

unread,
Jun 12, 2008, 12:44:53 PM6/12/08
to Inria Ocaml Mailing List
I am trying to use sexplib to serialize some data structures, as many of you
advised, and I am somewhat stuck trying to compile.
This is what I get:

ocamlfind ocamlc -package
unix,str,vec,mapmin,hashtbl_bounded,fileinfo,intvmap,extlib,mysql,sexplib -I
./../batch/analysis -I +camlp4 -pp camlp4orf -g -c online_db.ml
File "online_db.ml", line 44, characters 22-26:
Parse error: [semi] expected after [str_item] (in [implem])
Preprocessor error

where my line 44 is simply:

type foo_t = int list with sexp

I have the impression that the problem is in how I compile. Specifically,
if I do not use the "-pp camlp4orf" part, I get a "syntax error", as the
file is not getting preprocessed.
If I use the above -pp line, I get the error I reported. I am not sure what
is the proper way to preprocess the file, and unfortunately, sexplib does
not explain how to compile code against it.
I am sure this is obvious for everybody, but it is the first time I use
camlp4, so some help would be appreciated.

All the best,

Luca

Gerd Stolpmann

unread,
Jun 12, 2008, 1:27:01 PM6/12/08
to Luca de Alfaro, Inria Ocaml Mailing List

Am Donnerstag, den 12.06.2008, 09:44 -0700 schrieb Luca de Alfaro:
> I am trying to use sexplib to serialize some data structures, as many
> of you advised, and I am somewhat stuck trying to compile.
> This is what I get:
>
> ocamlfind ocamlc -package
> unix,str,vec,mapmin,hashtbl_bounded,fileinfo,intvmap,extlib,mysql,sexplib -I ../../batch/analysis -I +camlp4 -pp camlp4orf -g -c online_db.ml

> File "online_db.ml", line 44, characters 22-26:
> Parse error: [semi] expected after [str_item] (in [implem])
> Preprocessor error

I would try

ocamlfind ocamlc -package sexplib,... -syntax camlp4o -I ... -c
online_db.ml

ocamlfind includes some mechanics to drive camlp4, and I am pretty sure
sexplib configures that.

Gerd

>
> where my line 44 is simply:
>
> type foo_t = int list with sexp
>
> I have the impression that the problem is in how I compile.
> Specifically, if I do not use the "-pp camlp4orf" part, I get a
> "syntax error", as the file is not getting preprocessed.
> If I use the above -pp line, I get the error I reported. I am not
> sure what is the proper way to preprocess the file, and unfortunately,
> sexplib does not explain how to compile code against it.
> I am sure this is obvious for everybody, but it is the first time I
> use camlp4, so some help would be appreciated.
>
> All the best,
>
> Luca

> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
--
------------------------------------------------------------
Gerd Stolpmann * Viktoriastr. 45 * 64293 Darmstadt * Germany
ge...@gerd-stolpmann.de http://www.gerd-stolpmann.de
Phone: +49-6151-153855 Fax: +49-6151-997714
------------------------------------------------------------


_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

Markus Mottl

unread,
Jun 12, 2008, 2:43:12 PM6/12/08
to Gerd Stolpmann, Inria Ocaml Mailing List
On Thu, Jun 12, 2008 at 1:28 PM, Gerd Stolpmann <in...@gerd-stolpmann.de> wrote:
> ocamlfind includes some mechanics to drive camlp4, and I am pretty sure
> sexplib configures that.

Since we do not use packages in our build tree (all used libraries are
part of the tree anyway), we have hardly tested the ocamlfind rules in
the sexplib META file. I'm pretty sure they are not complete or
correct. I don't know enough about ocamlfind to quickly solve this
issue. If anybody more knowledgeable (Gerd? ;) knows what to add to
the META file to make this work, I'd be glad to update the sexplib
distribution quickly.

Regards,
Markus

--
Markus Mottl http://www.ocaml.info markus...@gmail.com

Markus Mottl

unread,
Jun 12, 2008, 3:18:03 PM6/12/08
to Gerd Stolpmann, Inria Ocaml Mailing List
On Thu, Jun 12, 2008 at 1:28 PM, Gerd Stolpmann <in...@gerd-stolpmann.de> wrote:
>> This is what I get:
>>
>> ocamlfind ocamlc -package
>> unix,str,vec,mapmin,hashtbl_bounded,fileinfo,intvmap,extlib,mysql,sexplib -I ../../batch/analysis -I +camlp4 -pp camlp4orf -g -c online_db.ml
>> File "online_db.ml", line 44, characters 22-26:
>> Parse error: [semi] expected after [str_item] (in [implem])
>> Preprocessor error

I have taken another quick look at this problem. Here is the solution:

Use "sexplib.syntax" instead of "sexplib" as package, add "-syntax
camlp4o", and drop "-I +camlp4 -pp camlp4orf". This should fix the
problem.

Regards,
Markus

_______________________________________________

Sylvain Le Gall

unread,
Jun 12, 2008, 3:24:26 PM6/12/08
to caml...@inria.fr
Hello,

On 12-06-2008, Markus Mottl <markus...@gmail.com> wrote:
> On Thu, Jun 12, 2008 at 1:28 PM, Gerd Stolpmann <in...@gerd-stolpmann.de> wrote:
>> ocamlfind includes some mechanics to drive camlp4, and I am pretty sure
>> sexplib configures that.
>
> Since we do not use packages in our build tree (all used libraries are
> part of the tree anyway), we have hardly tested the ocamlfind rules in
> the sexplib META file. I'm pretty sure they are not complete or
> correct. I don't know enough about ocamlfind to quickly solve this
> issue. If anybody more knowledgeable (Gerd? ;) knows what to add to
> the META file to make this work, I'd be glad to update the sexplib
> distribution quickly.


META in sexplib310 (3.7.4, the one distributed in debian unstable), is
all you need.

You just have to to compile using
"ocamlfind ocamlc .... -package sexplib.syntax -syntax camlp4o ..."

At least, it works for me.

Regards,
Sylvain Le Gall

Ian Pye

unread,
Jun 13, 2008, 4:24:04 AM6/13/08
to Sylvain Le Gall, caml...@inria.fr
Hi,

I am trying the above solution, and getting this:

ocamlfind ocamlc -package
unix,str,vec,mapmin,hashtbl_bounded,fileinfo,intvmap,extlib,mysql,sexplib.syntax
-syntax camlp4o -I ../../batch/analysis -g -c online_db.ml

File "online_db.ml", line 44, characters 27-31:
Failure: "Pa_type_conv: path not set"
Preprocessor error

At least its something different.

Ian

Sylvain Le Gall

unread,
Jun 13, 2008, 4:33:46 AM6/13/08
to caml...@inria.fr
Hello,

On Thu, Jun 12, 2008 at 03:02:30PM -0700, Ian Pye wrote:
> Hi,
>
> I am trying the above solution, and getting this:
>
> ocamlfind ocamlc -package
> unix,str,vec,mapmin,hashtbl_bounded,fileinfo,intvmap,extlib,mysql,sexplib.syntax
> -syntax camlp4o -I ../../batch/analysis -g -c online_db.ml
>
> File "online_db.ml", line 44, characters 27-31:
> Failure: "Pa_type_conv: path not set"
> Preprocessor error
>

Read the documentation ;-)

You need to add something like:

TYPE_CONV_PATH "CsvGenerator"

in your .ml file.

Regards

0 new messages