Compiling an "hello world" example

10 views
Skip to first unread message

OGrandeDiEnne

unread,
Dec 14, 2010, 12:26:49 PM12/14/10
to micmatch
Hello people,
I am trying to compile a stupid example, just to be sure that my
developing environment is ok.

I tried to compile one single file, as indicated in the project home
page ( http://martin.jambon.free.fr/micmatch.html ):

ocamlopt -c -pp "camlp4o -I $MICMATCHDIR pa_mikmatch_pcre.cma"
inputstring.ml

File "ghost-location", line 1, characters 0-0:
Error: Unbound value Pcre.regexp

Any hint ?
Yes, i have installed the Pcre-ocaml library. Maybe in the wrong
version ?


By the way in the webpage there's an error: mikmatch_pcre.cma in the
compilation line is with the "c" instead of the "k".

Thanks for the help,

O( n )

Martin Jambon

unread,
Dec 14, 2010, 1:30:14 PM12/14/10
to micm...@googlegroups.com
On 12/14/10 09:26, OGrandeDiEnne wrote:
> Hello people,
> I am trying to compile a stupid example, just to be sure that my
> developing environment is ok.
>
> I tried to compile one single file, as indicated in the project home
> page ( http://martin.jambon.free.fr/micmatch.html ):
>
> ocamlopt -c -pp "camlp4o -I $MICMATCHDIR pa_mikmatch_pcre.cma"
> inputstring.ml
>
> File "ghost-location", line 1, characters 0-0:
> Error: Unbound value Pcre.regexp
>
> Any hint ?

Yes, that's because your $MICMATCHDIR is undefined.
You should follow the recommended approach, using ocamlfind:

ocamlfind ocamlopt -c -syntax camlp4o \
-package mikmatch_pcre \
hello.ml

ocamlfind ocamlopt -o hello -syntax camlp4o \
-package mikmatch_pcre \
-linkpkg hello.cmx

> Yes, i have installed the Pcre-ocaml library. Maybe in the wrong
> version ?
>
>
> By the way in the webpage there's an error: mikmatch_pcre.cma in the
> compilation line is with the "c" instead of the "k".

That's not an error, it's because two different versions exist:
- the original one (c), which now works only with camlp5
- the newer one (k), which only works with the "new" camlp4, i.e. the
one that comes with the ocaml distribution (>= 3.10).


Martin

OGrandeDiEnne

unread,
Dec 15, 2010, 7:04:54 AM12/15/10
to micmatch


On Dec 14, 7:30 pm, Martin Jambon <mar...@mjambon.com> wrote:

> > ocamlopt -c   -pp "camlp4o -I  $MICMATCHDIR pa_mikmatch_pcre.cma"
> > inputstring.ml
>
> > File "ghost-location", line 1, characters 0-0:
> > Error: Unbound value Pcre.regexp

> Yes, that's because your $MICMATCHDIR is undefined.
> You should follow the recommended approach, using ocamlfind:


$MICMATCHDIR is defined; infact if i compile without the include dir,
i get a different error:

$ echo $MICMATCHDIR
/usr/local/lib/ocaml/3.11.2/mikmatch_pcre/

$ ocamlopt -c -pp "camlp4o pa_mikmatch_pcre.cma" inputstring.ml
Camlp4: Uncaught exception: DynLoader.Error ("pa_mikmatch_pcre.cma",
"file not found in path")

File "inputstring.ml", line 1, characters 0-1:
Error: Preprocessor error


>
> ocamlfind ocamlopt -c       -syntax camlp4o \
>                             -package mikmatch_pcre \
>                                      hello.ml
>
> ocamlfind ocamlopt -o hello -syntax camlp4o \
>                             -package mikmatch_pcre \
>                             -linkpkg hello.cmx
>

Ok, now it compiles. I tried that before but didn't work because
tophide was missing; I didn't read about this dependency.


> > By the way in the webpage there's an error: mikmatch_pcre.cma in the
> > compilation line is with the "c" instead of the "k".
>
> That's not an error, it's because two different versions exist:
> - the original one (c), which now works only with camlp5
> - the newer one (k), which only works with the "new" camlp4, i.e. the
> one that comes with the ocaml distribution (>= 3.10).

Good. I knew about different versions but I didn't notice the name
difference.


O( n )
Reply all
Reply to author
Forward
0 new messages