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
Sorry, forget to say, I tried this under cygwin.
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
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
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
_______________________________________________
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:
(Although more recent versions of findlib include the necessary
correction).
So you could try the patch above, or try a later version of findlib.
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
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
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)
>
> 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
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
------------------------------------------------------------
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
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
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