caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* camlp4 -I and shared libs
@ 2007-06-25  3:33 Jake Donham
  2007-06-25 12:57 ` [Caml-list] " Martin Jambon
  0 siblings, 1 reply; 12+ messages in thread
From: Jake Donham @ 2007-06-25  3:33 UTC (permalink / raw)
  To: caml-list

Hi,

Should the -I flag to camlp4 add the directory to the shared library
search path, as it does with ocamlc?

I was trying to use Micmatch (very nice by the way) with ocamlfind, as follows:

  ocamlfind ocamlc -syntax camlp4o -ppopt pa_micmatch_pcre.cmo
-package micmatch_pcre [...]

but I get an error that it cannot find dllpcre.so. What is happening
is that ocamlfind has pcre-ocaml as a dependency of micmatch_pcre
(even though this is needed only at runtime, not at preprocessing
time), so it adds pcre.cma and -I $SITE_LIB/pcre to the camlp4 command
line. Now pcre.cma needs dllpcre.so, which is in $SITE_LIB/pcre, but
this path is not added to the shared library search path. (It's easy
to work around this by constructing a camlp4 call directly, since
pcre.cma is not needed.)

This is with 3.09.3 but a glance at the 3.10.0 source suggests it has
the same behavior. It's a one-line change (call Dll.add_path after
Dynlink.init in camlp4/odyl/odyl_main.ml or
camlp4/CamlP4/Struct/DynLoader.ml) to fix it.

Thanks,

Jake


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

* Re: [Caml-list] camlp4 -I and shared libs
  2007-06-25  3:33 camlp4 -I and shared libs Jake Donham
@ 2007-06-25 12:57 ` Martin Jambon
  2007-06-25 14:19   ` Nicolas Pouillard
  0 siblings, 1 reply; 12+ messages in thread
From: Martin Jambon @ 2007-06-25 12:57 UTC (permalink / raw)
  To: Jake Donham; +Cc: caml-list

On Sun, 24 Jun 2007, Jake Donham wrote:

> Hi,
>
> Should the -I flag to camlp4 add the directory to the shared library
> search path, as it does with ocamlc?
>
> I was trying to use Micmatch (very nice by the way) with ocamlfind, as 
> follows:

(thanks)

> ocamlfind ocamlc -syntax camlp4o -ppopt pa_micmatch_pcre.cmo
> -package micmatch_pcre [...]

It seems you forgot either -c or -linkpkg.
The following should work.

ocamlfind ocamlc -c -syntax camlp4o -package micmatch_pcre toto.ml
ocamlfind ocamlc -o toto -syntax camlp4o -package micmatch_pcre -linkpkg toto.ml


> but I get an error that it cannot find dllpcre.so. What is happening
> is that ocamlfind has pcre-ocaml as a dependency of micmatch_pcre
> (even though this is needed only at runtime, not at preprocessing
> time), so it adds pcre.cma and -I $SITE_LIB/pcre to the camlp4 command
> line. Now pcre.cma needs dllpcre.so, which is in $SITE_LIB/pcre, but
> this path is not added to the shared library search path. (It's easy
> to work around this by constructing a camlp4 call directly, since
> pcre.cma is not needed.)
>
> This is with 3.09.3 but a glance at the 3.10.0 source suggests it has
> the same behavior. It's a one-line change (call Dll.add_path after
> Dynlink.init in camlp4/odyl/odyl_main.ml or
> camlp4/CamlP4/Struct/DynLoader.ml) to fix it.

Note that the current version of micmatch does not work under ocaml/camlp4 
3.10.0. I recommend using 3.09.3 until the new camlp4 is more mature.


Martin


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

* Re: [Caml-list] camlp4 -I and shared libs
  2007-06-25 12:57 ` [Caml-list] " Martin Jambon
@ 2007-06-25 14:19   ` Nicolas Pouillard
  2007-06-25 18:24     ` Jake Donham
  2007-06-29  7:49     ` Hendrik Tews
  0 siblings, 2 replies; 12+ messages in thread
From: Nicolas Pouillard @ 2007-06-25 14:19 UTC (permalink / raw)
  To: Martin Jambon; +Cc: Jake Donham, caml-list

On 6/25/07, Martin Jambon <martin.jambon@ens-lyon.org> wrote:
> On Sun, 24 Jun 2007, Jake Donham wrote:
>
> > Hi,
> >
> > Should the -I flag to camlp4 add the directory to the shared library
> > search path, as it does with ocamlc?
> >
> > I was trying to use Micmatch (very nice by the way) with ocamlfind, as
> > follows:
>
> (thanks)
>
> > ocamlfind ocamlc -syntax camlp4o -ppopt pa_micmatch_pcre.cmo
> > -package micmatch_pcre [...]
>
> It seems you forgot either -c or -linkpkg.
> The following should work.
>
> ocamlfind ocamlc -c -syntax camlp4o -package micmatch_pcre toto.ml
> ocamlfind ocamlc -o toto -syntax camlp4o -package micmatch_pcre -linkpkg toto.ml
>
>
> > but I get an error that it cannot find dllpcre.so. What is happening
> > is that ocamlfind has pcre-ocaml as a dependency of micmatch_pcre
> > (even though this is needed only at runtime, not at preprocessing
> > time), so it adds pcre.cma and -I $SITE_LIB/pcre to the camlp4 command
> > line. Now pcre.cma needs dllpcre.so, which is in $SITE_LIB/pcre, but
> > this path is not added to the shared library search path. (It's easy
> > to work around this by constructing a camlp4 call directly, since
> > pcre.cma is not needed.)
> >
> > This is with 3.09.3 but a glance at the 3.10.0 source suggests it has
> > the same behavior. It's a one-line change (call Dll.add_path after
> > Dynlink.init in camlp4/odyl/odyl_main.ml or
> > camlp4/CamlP4/Struct/DynLoader.ml) to fix it.
>
> Note that the current version of micmatch does not work under ocaml/camlp4
> 3.10.0. I recommend using 3.09.3 until the new camlp4 is more mature.

No major change is planned for Camlp4. I think that's reasonable to
start translating extensions.

-- 
Nicolas Pouillard


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

* Re: [Caml-list] camlp4 -I and shared libs
  2007-06-25 14:19   ` Nicolas Pouillard
@ 2007-06-25 18:24     ` Jake Donham
  2007-06-27  5:32       ` Jake Donham
  2007-06-29  7:49     ` Hendrik Tews
  1 sibling, 1 reply; 12+ messages in thread
From: Jake Donham @ 2007-06-25 18:24 UTC (permalink / raw)
  To: Martin Jambon, caml-list

> It seems you forgot either -c or -linkpkg.
> The following should work.
>
> ocamlfind ocamlc -c -syntax camlp4o -package micmatch_pcre toto.ml
> ocamlfind ocamlc -o toto -syntax camlp4o -package micmatch_pcre -linkpkg toto.ml

Thanks for the reply. This does not seem to be the problem however. In
my last message I was recreating from memory--here is my actual
command line and the response:

ocamlfind ocamlc -g -syntax camlp4o -ppopt pa_micmatch_pcre.cmo
-package extlib,calendar,camlpdf,micmatch_pcre -I .. -c scrape.ml
Error while loading "/usr/local/lib/ocaml/site-lib/pcre/pcre.cma":
error loading shared library: dllpcre_stubs.so: cannot open shared
object file: No such file or directory.
Preprocessor error.

I spent some time debugging it, and I see no way that the dynamic
loading code could find dllpcre_stubs.so without the appropriate path
being added. Thanks,

Jake


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

* Re: [Caml-list] camlp4 -I and shared libs
  2007-06-25 18:24     ` Jake Donham
@ 2007-06-27  5:32       ` Jake Donham
  0 siblings, 0 replies; 12+ messages in thread
From: Jake Donham @ 2007-06-27  5:32 UTC (permalink / raw)
  To: Martin Jambon, caml-list

On 6/25/07, Jake Donham <jake.donham@skydeck.com> wrote:
> error loading shared library: dllpcre_stubs.so: cannot open shared
> object file: No such file or directory.

Sorry, this was my bug. Somehow I messed up my ld.conf and didn't
notice it. Thanks for your help.

Jake


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

* Re: [Caml-list] camlp4 -I and shared libs
  2007-06-25 14:19   ` Nicolas Pouillard
  2007-06-25 18:24     ` Jake Donham
@ 2007-06-29  7:49     ` Hendrik Tews
  2007-06-29  9:39       ` Nicolas Pouillard
  1 sibling, 1 reply; 12+ messages in thread
From: Hendrik Tews @ 2007-06-29  7:49 UTC (permalink / raw)
  To: caml-list

"Nicolas Pouillard" <nicolas.pouillard@gmail.com> writes:

   No major change is planned for Camlp4. I think that's reasonable to
   start translating extensions.

Where is the documentation?

Hendrik


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

* Re: [Caml-list] camlp4 -I and shared libs
  2007-06-29  7:49     ` Hendrik Tews
@ 2007-06-29  9:39       ` Nicolas Pouillard
  2007-06-29 10:23         ` Robert Roessler
  2007-06-29 12:41         ` skaller
  0 siblings, 2 replies; 12+ messages in thread
From: Nicolas Pouillard @ 2007-06-29  9:39 UTC (permalink / raw)
  To: Hendrik Tews; +Cc: caml-list

On 6/29/07, Hendrik Tews <H.Tews@cs.ru.nl> wrote:
> "Nicolas Pouillard" <nicolas.pouillard@gmail.com> writes:
>
>    No major change is planned for Camlp4. I think that's reasonable to
>    start translating extensions.
>
> Where is the documentation?

http://brion.inria.fr/gallium/index.php/Camlp4

-- 
Nicolas Pouillard


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

* Re: [Caml-list] camlp4 -I and shared libs
  2007-06-29  9:39       ` Nicolas Pouillard
@ 2007-06-29 10:23         ` Robert Roessler
  2007-06-29 10:44           ` Benedikt Grundmann
  2007-06-29 12:41         ` skaller
  1 sibling, 1 reply; 12+ messages in thread
From: Robert Roessler @ 2007-06-29 10:23 UTC (permalink / raw)
  To: Caml-list

Nicolas Pouillard wrote:
> On 6/29/07, Hendrik Tews <H.Tews@cs.ru.nl> wrote:
>> "Nicolas Pouillard" <nicolas.pouillard@gmail.com> writes:
>>
>>    No major change is planned for Camlp4. I think that's reasonable to
>>    start translating extensions.
>>
>> Where is the documentation?
> 
> http://brion.inria.fr/gallium/index.php/Camlp4

Ah, it's the old "You do not like our docs?  Here is the wiki - feel 
free to contribute" trick. ;)

Robert Roessler
roessler@rftp.com
http://www.rftp.com


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

* Re: [Caml-list] camlp4 -I and shared libs
  2007-06-29 10:23         ` Robert Roessler
@ 2007-06-29 10:44           ` Benedikt Grundmann
  2007-06-29 14:06             ` Nicolas Pouillard
  0 siblings, 1 reply; 12+ messages in thread
From: Benedikt Grundmann @ 2007-06-29 10:44 UTC (permalink / raw)
  To: Robert Roessler; +Cc: Caml-list

Hi everybody,

At the risk of sounding harsh, I do not like this wiki at all, due to
several reasons:

1) Default style sheet is a partial user interface nightmare, a lot of
the links are embedded in  titles, which happen to have nearly the
same styling... So you actually have to hover above each title to find
the links.

2) Structure is a mess...  Camlp4 can do a lot and that is great.  But
I do believe that the primary motivation is the extension of OCaml and
some simple examples, or even better yet some kind of tutorial is
needed. It definitely should start simple maybe even over simplifying
things and very very gradually introduce the true power...

Anyway I personally learned more from the extremely short page at:

http://www.ocaml-tutorial.org/camlp4_3.10

In particular the link to json_static was helpful.

In that spirit here is a link to a syntax extension that I am writing
as part of the OCaml Summer Project:
http://osprepo.janestcapital.com/trac/osp2007/browser/osp/2007/econcurrency/trunk/src/pa_receive.ml

Cheers,

Bene

PS: I do not want to start a flame war, or offend the creators of the
Wiki.  I just wanted to point out that right now the wiki is not
helpful, unless you already now a lot about camlp4...

PPS: My syntax extension captures the identifier msg.  How is one
supposed to write hygienic macros?  Should I just store a counter
somewhere and generate identifiers like "msg__32432" and hope that
nobody else uses the same prefix, or is there some support for things
like that in camlp4?



2007/6/29, Robert Roessler <roessler@rftp.com>:
> Nicolas Pouillard wrote:
> > On 6/29/07, Hendrik Tews <H.Tews@cs.ru.nl> wrote:
> >> "Nicolas Pouillard" <nicolas.pouillard@gmail.com> writes:
> >>
> >>    No major change is planned for Camlp4. I think that's reasonable to
> >>    start translating extensions.
> >>
> >> Where is the documentation?
> >
> > http://brion.inria.fr/gallium/index.php/Camlp4
>
> Ah, it's the old "You do not like our docs?  Here is the wiki - feel
> free to contribute" trick. ;)
>
> Robert Roessler
> roessler@rftp.com
> http://www.rftp.com
>
> _______________________________________________
> 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
>


-- 
Calvin: I try to make everyone's day a little more
surreal.

(From Calvin & Hobbes)


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

* Re: [Caml-list] camlp4 -I and shared libs
  2007-06-29  9:39       ` Nicolas Pouillard
  2007-06-29 10:23         ` Robert Roessler
@ 2007-06-29 12:41         ` skaller
  2007-06-29 13:48           ` Nicolas Pouillard
  1 sibling, 1 reply; 12+ messages in thread
From: skaller @ 2007-06-29 12:41 UTC (permalink / raw)
  To: Nicolas Pouillard; +Cc: Hendrik Tews, caml-list

On Fri, 2007-06-29 at 11:39 +0200, Nicolas Pouillard wrote:
> On 6/29/07, Hendrik Tews <H.Tews@cs.ru.nl> wrote:
> > "Nicolas Pouillard" <nicolas.pouillard@gmail.com> writes:
> >
> >    No major change is planned for Camlp4. I think that's reasonable to
> >    start translating extensions.
> >
> > Where is the documentation?
> 
> http://brion.inria.fr/gallium/index.php/Camlp4

Ahem .. "login/create account" does not allow you
to create an account, and you have to have an account
to edit pages .. :)


-- 
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net


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

* Re: [Caml-list] camlp4 -I and shared libs
  2007-06-29 12:41         ` skaller
@ 2007-06-29 13:48           ` Nicolas Pouillard
  0 siblings, 0 replies; 12+ messages in thread
From: Nicolas Pouillard @ 2007-06-29 13:48 UTC (permalink / raw)
  To: skaller; +Cc: Hendrik Tews, caml-list

On 6/29/07, skaller <skaller@users.sourceforge.net> wrote:
> On Fri, 2007-06-29 at 11:39 +0200, Nicolas Pouillard wrote:
> > On 6/29/07, Hendrik Tews <H.Tews@cs.ru.nl> wrote:
> > > "Nicolas Pouillard" <nicolas.pouillard@gmail.com> writes:
> > >
> > >    No major change is planned for Camlp4. I think that's reasonable to
> > >    start translating extensions.
> > >
> > > Where is the documentation?
> >
> > http://brion.inria.fr/gallium/index.php/Camlp4
>
> Ahem .. "login/create account" does not allow you
> to create an account, and you have to have an account
> to edit pages .. :)
>

Yes that's a pain. You have to send me an email to have one. You want
one, which login?

-- 
Nicolas Pouillard


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

* Re: [Caml-list] camlp4 -I and shared libs
  2007-06-29 10:44           ` Benedikt Grundmann
@ 2007-06-29 14:06             ` Nicolas Pouillard
  0 siblings, 0 replies; 12+ messages in thread
From: Nicolas Pouillard @ 2007-06-29 14:06 UTC (permalink / raw)
  To: Benedikt Grundmann; +Cc: Robert Roessler, Caml-list

On 6/29/07, Benedikt Grundmann <benedikt@cardexpert.net> wrote:
> Hi everybody,
>
> At the risk of sounding harsh, I do not like this wiki at all, due to
> several reasons:
>
> 1) Default style sheet is a partial user interface nightmare, a lot of
> the links are embedded in  titles, which happen to have nearly the
> same styling... So you actually have to hover above each title to find
> the links.

You're right.

> 2) Structure is a mess...  Camlp4 can do a lot and that is great.  But
> I do believe that the primary motivation is the extension of OCaml and
> some simple examples, or even better yet some kind of tutorial is
> needed. It definitely should start simple maybe even over simplifying
> things and very very gradually introduce the true power...

Yes but, for now I was more concentrated on explaining differences and
improvements, and that's about advanced features.

[...]

> PS: I do not want to start a flame war, or offend the creators of the
> Wiki.  I just wanted to point out that right now the wiki is not
> helpful, unless you already now a lot about camlp4...

That's a good point, that I am aware of.

> PPS: My syntax extension captures the identifier msg.  How is one
> supposed to write hygienic macros?  Should I just store a counter
> somewhere and generate identifiers like "msg__32432" and hope that
> nobody else uses the same prefix, or is there some support for things
> like that in camlp4?

You can start by checking that the user don't use that variable.

Using the generated fold it's easy.

$ cat foo.ml
open Camlp4.PreCast;;
let filter = object (o) inherit Ast.fold as super

  (* capture most of cases *)
  method ident i =
     let o = super#ident i in
     match i with
     | <:ident< msg >> -> failwith "msg forbidden"
     | _ -> o

  (* there is perhaps some more... *)
  method expr e =
     let o = super#expr e in
     match e with
     | <:expr< for msg = $_$ $to:_$ $_$ do $_$ done >> -> failwith
"msg forbidden"
     | _ -> o
end;;
AstFilters.register_str_item_filter (fun st -> let _ = filter#str_item st in st)

$ ocamlc -c -I +camlp4 -pp camlp4of foo.ml

$ cat bar.ml
let msg = 42

$ camlp4o ./foo.cmo bar.ml

-- 
Nicolas Pouillard


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

end of thread, other threads:[~2007-06-29 14:06 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-06-25  3:33 camlp4 -I and shared libs Jake Donham
2007-06-25 12:57 ` [Caml-list] " Martin Jambon
2007-06-25 14:19   ` Nicolas Pouillard
2007-06-25 18:24     ` Jake Donham
2007-06-27  5:32       ` Jake Donham
2007-06-29  7:49     ` Hendrik Tews
2007-06-29  9:39       ` Nicolas Pouillard
2007-06-29 10:23         ` Robert Roessler
2007-06-29 10:44           ` Benedikt Grundmann
2007-06-29 14:06             ` Nicolas Pouillard
2007-06-29 12:41         ` skaller
2007-06-29 13:48           ` Nicolas Pouillard

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