caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] darwin link suckage eg: pcre
@ 2002-12-14  7:00 jehenrik
  2002-12-14 11:32 ` Markus Mottl
  0 siblings, 1 reply; 2+ messages in thread
From: jehenrik @ 2002-12-14  7:00 UTC (permalink / raw)
  To: caml-list

Can somebody who understands Darwin linking tell me why my ocaml pcre 
does not work like I think it should?  I build pcre 3.9.  Install.  
Fine.  I build pcre-ocaml 4.28.  It installs in 
/usr/local/lib/ocaml/contrib.  Good enough.  After the install, I have 
to manually ranlib libpcre_stubs.a because the directory has changed.  
Fine.  The example programs, pcregrep et al, link fine against the 
install.  Now I try to build a toplevel:

> bash2.05 jehenrik@localhost ~/src/pcre-ocaml-4.28.3 % ocamlmktop -ccopt 
> -L/usr/local/lib/ocaml/contrib -o ocaml_pcre pcre.cma
> bash2.05 jehenrik@localhost ~/src/pcre-ocaml-4.28.3 % ocaml_pcre
>         Objective Caml version 3.06
>
> # open Pcre;;
> Unbound module Pcre
> # Pcre.regexp;;
> Unbound value Pcre.regexp

The toplevel executable does contain the C stubs:


> bash2.05 jehenrik@localhost ~/src/pcre-ocaml-4.28.3 % nm ocaml_pcre
> .
> .
> .
> 00002438 T _pcre_isspace_wrapper

OTOH, I can't seem to see them even if I load pcre.cmo:

> # #load "lib/pcre.cmo";;
> # Pcre;;
> Unbound constructor Pcre
> # Pcre.regexp;;
> Unbound value Pcre.regexp
> # regexp;;
> Unbound value regexp

I can see them if I ignore the .mli file and load all the symbols into 
the top namespace:

> # #use "lib/pcre.ml";;
> exception BadPattern of string * int
> exception InternalError of string
> .
> .
> .
> # regexp "[a-z]";;
> - : regexp = <abstr>
> #

Of course this isn't what I want, it's just duct tape.  Now I have a fix 
which I don't understand either.  I change

> ifndef OCAML_LIB_INSTALL
>   OCAML_LIB_INSTALL := $(OCAMLLIBPATH)
> JH was $(OCAMLLIBPATH)/contrib

in OcamlMakefile, reinstall, and everything works perfect:

> bash2.05 jehenrik@localhost ~/src/pcre-ocaml-4.28.3 % ocamlmktop 
> pcre.cma -o ocaml_pcre
> bash2.05 jehenrik@localhost ~/src/pcre-ocaml-4.28.3 % ocaml_pcre
>         Objective Caml version 3.06
>
> # open Pcre;;
> #

So I have a workaround, but I would like to know what the problem is so 
that I don't repeat whatever error is here with my own code.  Thanks.


Jeff Henrikson


-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

* Re: [Caml-list] darwin link suckage eg: pcre
  2002-12-14  7:00 [Caml-list] darwin link suckage eg: pcre jehenrik
@ 2002-12-14 11:32 ` Markus Mottl
  0 siblings, 0 replies; 2+ messages in thread
From: Markus Mottl @ 2002-12-14 11:32 UTC (permalink / raw)
  To: jehenrik; +Cc: caml-list

On Sat, 14 Dec 2002, jehenrik wrote:
> >bash2.05 jehenrik@localhost ~/src/pcre-ocaml-4.28.3 % ocaml_pcre
> >        Objective Caml version 3.06
> >
> ># open Pcre;;
> >Unbound module Pcre
> ># Pcre.regexp;;
> >Unbound value Pcre.regexp

Toplevels always require include paths, i.e. you should either start it
as follows:

  ocaml_pcre -I +contrib

Or as usual but include the path within the toplevel:

  ocaml_pcre
  # #directory "+contrib";;

> ># #load "lib/pcre.cmo";;
> ># Pcre;;
> >Unbound constructor Pcre

This wouldn't work anyway, because here Pcre is not interpreted as
a module name but as a constructor. You either need to "open Pcre" or
access one of the names contained within it with a fully qualified name,
e.g. "Pcre.regexp". Even then the above example wouldn't work, because
the compiled interface file "pcre.cmi" also needs to be visible. This
can only be done in the way explained above.

> Of course this isn't what I want, it's just duct tape.  Now I have a fix 
> which I don't understand either.  I change
> 
> >ifndef OCAML_LIB_INSTALL
> >  OCAML_LIB_INSTALL := $(OCAMLLIBPATH)
> >JH was $(OCAMLLIBPATH)/contrib
> 
> in OcamlMakefile, reinstall, and everything works perfect:

Sure, because the standard directory is always in the search path of
toplevels.

Regards,
Markus Mottl

-- 
Markus Mottl                                             markus@oefai.at
Austrian Research Institute
for Artificial Intelligence                  http://www.oefai.at/~markus
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

end of thread, other threads:[~2002-12-14 11:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-12-14  7:00 [Caml-list] darwin link suckage eg: pcre jehenrik
2002-12-14 11:32 ` Markus Mottl

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