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

[Caml-list] Dynlink and ocamlfind for camlp4 3.11?

50 views
Skip to first unread message

Conglun Yao

unread,
Oct 4, 2009, 10:22:47 AM10/4/09
to caml...@yquem.inria.fr
Dear all,

I have tried to use json-static in OCaml 3.11, but met the annoying problem:

Reference to undefined global `Dynlink'


As Camlp4 3.11 requires explicit load of dynlink, so I tried

ocamlfind ocamlc -package dynlink, json-static -syntax
camlp4o -o test test.ml -linkpkg

But failed with the same error.

Thanks for any help.

Conglun

Conglun Yao

unread,
Oct 4, 2009, 10:24:49 AM10/4/09
to caml...@yquem.inria.fr


Sorry, forget to say, I tried this under cygwin.

Richard Jones

unread,
Oct 4, 2009, 3:05:20 PM10/4/09
to Conglun Yao, caml...@yquem.inria.fr
On Sun, Oct 04, 2009 at 03:22:31PM +0100, Conglun Yao wrote:
> Dear all,
>
> I have tried to use json-static in OCaml 3.11, but met the annoying problem:
>
> Reference to undefined global `Dynlink'
>
>
> As Camlp4 3.11 requires explicit load of dynlink, so I tried
>
> ocamlfind ocamlc -package dynlink, json-static -syntax
> camlp4o -o test test.ml -linkpkg

Is there really a space in "dynlink, json-static". You'll need to try
it without the space, or quote it.

Rich.

--
Richard Jones
Red Hat

_______________________________________________
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

Conglun Yao

unread,
Oct 4, 2009, 3:32:29 PM10/4/09
to Richard Jones, caml...@yquem.inria.fr
Thanks, Rich.

ocamlfind ocamlc -package dynlink,json-static -syntax camlp4o -c test.ml
ocamlfind ocamlc -package "dynlink,json-static" -syntax camlp4o -c test.ml
ocamlfind ocamlc -package 'dynlink,json-static' -syntax camlp4o -c test.ml

But it still does not work.

System: cygwin + OCaml 3.11.1 + findlib 1.2.5 + json-staic 0,9.8

Everything works fine when I use Ubuntu, but when changed to cygwin, it
breaks.

Conglun

Richard Jones

unread,
Oct 4, 2009, 3:37:50 PM10/4/09
to Conglun Yao, caml...@yquem.inria.fr
On Sun, Oct 04, 2009 at 08:32:17PM +0100, Conglun Yao wrote:
> Thanks, Rich.
>
> ocamlfind ocamlc -package dynlink,json-static -syntax camlp4o -c test.ml
> ocamlfind ocamlc -package "dynlink,json-static" -syntax camlp4o -c test.ml
> ocamlfind ocamlc -package 'dynlink,json-static' -syntax camlp4o -c test.ml
>
> But it still does not work.
>
> System: cygwin + OCaml 3.11.1 + findlib 1.2.5 + json-staic 0,9.8

In that case, try listing dynlink explicitly, like:

ocamlfind ocamlc dynlink.cma -package json-static [etc]

Anyhow, it sounds like a bug in the META files that are supplied with
your cygwin OCaml distribution.

Rich.

--
Richard Jones
Red Hat

_______________________________________________

Richard Jones

unread,
Oct 4, 2009, 4:34:07 PM10/4/09
to Conglun Yao, caml...@yquem.inria.fr
On Sun, Oct 04, 2009 at 08:53:50PM +0100, Conglun Yao wrote:
> $ ocamlfind ocamlc dynlink.cma -package json-static -syntax camlp4o -c
> test.ml
>
> $ ocamlfind ocamlc -I /home/conglun/godi/lib/ocaml/pkg-lib/camlp4
> dynlink.cma -package json-static -syntax camlp4o -c t.ml
>
>
> Error: Error while linking
> /home/conglun/godi/lib/ocaml/std-lib/camlp4/camlp4lib.cma(Camlp4):

> Reference to undefined global `Dynlink'

OK, I remember what this one is now. camlp4 in 3.11.0 introduced an
extra dependency on Dynlink, and in the other distributions of OCaml
this meant that certain META files (distributed with findlib) had to
change.

This was the patch that we added for Fedora to fix the relevant META
file:

http://cvs.fedoraproject.org/viewvc/devel/ocaml-findlib/ocaml-findlib-1.2.3-camlp4-META.patch?revision=1.1&view=markup

(Although more recent versions of findlib include the necessary
correction).

So you could try the patch above, or try a later version of findlib.

Richard Jones

unread,
Oct 4, 2009, 4:35:26 PM10/4/09
to Conglun Yao, caml...@yquem.inria.fr
Ah but wait, your META file has that patch incorporated already!

I don't know -- the cygwin distribution of OCaml is broken somehow.

David Allsopp

unread,
Oct 4, 2009, 5:14:38 PM10/4/09
to Richard Jones, Conglun Yao, caml...@yquem.inria.fr
> Ah but wait, your META file has that patch incorporated already!
>
> I don't know -- the cygwin distribution of OCaml is broken somehow.

What happens if you run ocaml and then enter #load "dynlink.cma";; ??


David

Conglun Yao

unread,
Oct 4, 2009, 5:40:36 PM10/4/09
to David Allsopp, Richard Jones, caml...@yquem.inria.fr
Thanks for all of your help.


I tried, and it works fine until the require of "json-static". It breaks
when loading "pcre.cma".

Now we can say that pcre package has some problem, but dynlink is loaded
successfully.

Test1

$ ocaml
Objective Caml version 3.11.1

# #load "dynlink.cma";;
# let x = Dynlink.is_native;;
val x : bool = false

Test 2

$ocaml

#use "topfind";;
#load "dynlink.cma";;
#require "json-static";;
/home/conglun/godi/lib/ocaml/std-lib/dynlink.cma: loaded
/home/conglun/godi/lib/ocaml/std-lib/camlp4: added to search path
/home/conglun/godi/lib/ocaml/pkg-lib/pcre: added to search path
/home/conglun/godi/lib/ocaml/pkg-lib/pcre/pcre.cma: loaded
47721 [main] ocaml 2136 _cygtls::handle_exceptions: Error while dumping
state (probably corrupted stack)
Segmentation fault (core dumped)

Test 3

ocamlfind ocamlmktop -package dynlink -o dtop -custom -linkall

$./dtop

#use "topfind";;
#require "dynlink";;
/home/conglun/godi/lib/ocaml/std-lib/dynlink.cma: loaded
# let x = Dynlink.is_native;;
val x : bool = false

David Allsopp

unread,
Oct 5, 2009, 3:39:29 AM10/5/09
to caml...@yquem.inria.fr
> I tried, and it works fine until the require of "json-static". It breaks
when loading "pcre.cma".
>
> Now we can say that pcre package has some problem, but dynlink is loaded
successfully.

Hmm - a few other things to check:

1. Are you definitely using Cygwin's PCRE and which version (run pcre-config
--prefix and pcre-config --version)
2. Which version of ocaml-pcre is findlib trying to load (#use "topfind";;
#list;; from within ocaml)
3. Did you install the (very out-of-date) OCaml package which comes with
Cygwin?
4. Did you install plain GODI or did you pass -w32port mingw to the first
script?

I'm using pcre-ocaml 6.0.1 / PCRE 7.9 with no problems with the MinGW port
of OCaml 3.11.1 (not via GODI, though)

Conglun Yao

unread,
Oct 5, 2009, 6:14:25 AM10/5/09
to David Allsopp, caml...@yquem.inria.fr
On Mon, Oct 5, 2009 at 8:39 AM, David Allsopp <dra-...@metastack.com>wrote:

>
> Hmm - a few other things to check:
>
> 1. Are you definitely using Cygwin's PCRE and which version (run
> pcre-config
> --prefix and pcre-config --version)
>
2. Which version of ocaml-pcre is findlib trying to load (#use "topfind";;
> #list;; from within ocaml)
>

I don't use pcre directly, but packages like json-static depend on it.

pcre-config --prefix /usr/local
pcre-config ---version 7.9

The ocaml-pcre is version 6.0.1. Does it cause the problem?

Maybe I need to reinstall a 6.0.1 pcre.


> 3. Did you install the (very out-of-date) OCaml package which comes with
> Cygwin?

4. Did you install plain GODI or did you pass -w32port mingw to the first
> script?
>

No, I installed plain godi, which downloads and installs the OCaml 3.11.1

Gerd Stolpmann

unread,
Oct 5, 2009, 9:31:27 AM10/5/09
to Conglun Yao, caml...@yquem.inria.fr, Richard Jones

Am Sonntag, den 04.10.2009, 20:53 +0100 schrieb Conglun Yao:
>
>
>
>
> In that case, try listing dynlink explicitly, like:
>
> ocamlfind ocamlc dynlink.cma -package json-static [etc]
>
> $ ocamlfind ocamlc dynlink.cma -package json-static -syntax camlp4o -c
> test.ml
>
> $ ocamlfind ocamlc -I /home/conglun/godi/lib/ocaml/pkg-lib/camlp4
> dynlink.cma -package json-static -syntax camlp4o -c t.ml
>
>
> Error: Error while
> linking /home/conglun/godi/lib/ocaml/std-lib/camlp4/camlp4lib.cma(Camlp4):
> Reference to undefined global `Dynlink'
>
>
>
> Anyhow, it sounds like a bug in the META files that are
> supplied with
> your cygwin OCaml distribution.
>
>
>
>
> I think you are right, the problem happens on the camlp4o or cygwin,
> which can't load dynlink. But I can't find problem in the camlp4's
> META (in the attachment)

While cygwin cannot load shared libraries from bytecode, it still can
load pure bytecode dynamically. It is reasonable that there is a
dynlink.cma for this case, and that camlp4lib.cma depends on it.

findlib has a special mode for platforms that cannot load shared
libraries dynamically. This mode seems to be broken - it calls a script
safe_camlp4 instead of camlp4, and safe_camlp4 produces ad hoc a new
camlp4-type executable that includes the required C libraries - without
that trick you couldn't use json-static at all on these platforms:

https://godirepo.camlcity.org/svn/lib-findlib/trunk/tools/safe_camlp4

The question is now whether the error is in this script (does it have to
add dynlink.cma anyway?) or whether mkcamlp4 is broken.

Can you try to change safe_camlp4 so the line

mkcamlp4 -o $tmp_camlp4 $cp4_mods || exit

reads

mkcamlp4 -o $tmp_camlp4 dynlink.cma $cp4_mods || exit

? (I don't have a cygwin ocaml at hand.) safe_camlp4 should be in the
bin/ directory.

Gerd
--
------------------------------------------------------------
Gerd Stolpmann, Bad Nauheimer Str.3, 64289 Darmstadt,Germany
ge...@gerd-stolpmann.de http://www.gerd-stolpmann.de
Phone: +49-6151-153855 Fax: +49-6151-997714
------------------------------------------------------------

Conglun Yao

unread,
Oct 5, 2009, 11:17:49 AM10/5/09
to Gerd Stolpmann, caml...@yquem.inria.fr
Thanks for all of your help.

Unfortunately, it still does not work. It is really nightmare to use camp4
in a windows machine. I try to reinstall plain OCaml without using GODI, if
the same error happens, I have to go back to Ubuntu.

Thanks.

Conglun

David Allsopp

unread,
Oct 5, 2009, 1:28:41 PM10/5/09
to caml...@yquem.inria.fr
Conglun Yao wrote:
> Thanks for all of your help.
>
> Unfortunately, it still does not work. It is really nightmare to use camp4
in a windows machine.

In this instance, it's very much Cygwin that's causing the problem, rather
than Windows! I didn't realise that Cygwin's Dynlink only extended to pure
bytecode (it used not to have Dynlink at all).

> I try to reinstall plain OCaml without using GODI, if the same error
happens, I have to go back to Ubuntu.

You could try using the -w32port mingw flag for GODI to build the MinGW
version of OCaml - you can still use it from Cygwin's bash prompt but you
will definitely have a fully functional dynamic loading version.
Alternatively, if you want I can email you the instructions change log I use
for building MinGW & MSVC OCaml on Windows (one day I'll have the time to
put it online <sigh>).

Try GODI/MinGW first - building PCRE is not trivial and AFAIK GODI has full
build-support for ocaml-pcre on Windows.


David

Alain Frisch

unread,
Oct 5, 2009, 1:55:51 PM10/5/09
to Gerd Stolpmann, caml...@yquem.inria.fr, Richard Jones
Gerd Stolpmann wrote:
> While cygwin cannot load shared libraries from bytecode, it still can
> load pure bytecode dynamically.

Since OCaml 3.11 and the use of flexdll, all the windows ports
(including the Cygwin port) are supposed to be able to load stub DLLs
produced by flexlink. This has not been tested thoroughly, so feel free
to report otherwise if you can isolate a bug related to that.

Alain

0 new messages