Well, that's the wrong order of -lpcre -lpcre_stubs (must be the other
way round for static linking, while for dynamic linking there is no
requirement to give the -l archives in any particular order).
But I fear you are on your own with this issue. There is absolutely no
sensitivity for getting this right among ocaml developers. Even ocaml
itself makes it wrong:
g...@flake:~/tmp$ ocamlc -a -cclib -l1 -cclib -l2 -o t.cma t.cmo
g...@flake:~/tmp$ objinfo t.cma
File t.cma
Force custom: no
Extra C object files: -l2 -l1
...
g...@flake:~/tmp$ ocamlc -a -cclib -l1 -l2 -o t.cma t.cmo
g...@flake:~/tmp$ objinfo t.cma
File t.cma
Force custom: no
Extra C object files: -l2 -l1
...
Don't know why the order is not kept. It makes it really hard to
diagnose anything. So far I see, the arguments are again reverted when
the Extra C object files are used.
Anyway, I've fixed that for pcre, but you could run into any number of
similar issues when using libraries. Maybe it is better for you to
define a wrapper for ld that smuggles --start-group and --end-group
options in, so the search for symbols behaves like for shared linking.
Gerd
Am Mittwoch, den 23.12.2009, 16:22 -0600 schrieb Keith Waclena:
Gerd Stolpmann g...@gerd-stolpmann.de writes:
Peter, thanks for your concise analysis. I've patched godi-pcre as you
suggest.
Gerd
I've had a problem with godi-pcre for a while now that I've been too
lazy to post about. I was hoping this recent change might have fixed
it but it does not.
My problem is I can no longer statically link any of my ocaml apps
that use pcre; of course, this includes any of my apps that use
ocamlnet or pxp, so that's basically all my apps. I rely heavily on
statically-linked single-file ocaml executables in order to have
rock-solid unbreakable ocaml apps that survive OS upgrades and the
like, and which can be installed with no prerequisites.
I have the same exact problem on all my platforms: Linux, FreeBSD and
NetBSD (and I think Solaris and Mac OS X, though I haven't tested
thoroughly on those) and on both 32-bit and 64-bit systems. Also same
problem with 3.10 godi install.
Here's what happens when I try to statically link this test app:
let () =
if Pcre.pmatch ~pat:foo Sys.argv.(1)
then print_endline match
else print_endline NO
This is on Linux and I have done a full reinstall of 3.11 with the
latest rocketboost tarball.
$ ocamlbuild -lib pcre -cflags -I,$(ocamlfind query pcre) -lflags
-I,$(ocamlfind query pcre),-cclib,-static pcreproblem.native
Finished, 0 targets (0 cached) in 00:00:00.
+ ocamlfind ocamlopt -I /usr/app/godi-3.11/lib/ocaml/pkg-lib/pcre -cclib
-static pcre.cmxa -linkpkg pcreproblem.cmx -o pcreproblem.native
/usr/app/godi-3.11/lib/ocaml/std-lib/libasmrun.a(unix.o): In function
`caml_dlopen':
unix.c:(.text+0x234): warning: Using 'dlopen' in statically linked
applications requires at runtime the shared libraries from the glibc version
used for linking
/usr/app/godi-3.11/lib/ocaml/pkg-lib/pcre/libpcre_stubs.a(pcre_stubs.o):
In function `pcre_dealloc_tables':
pcre_stubs.c:(.text+0x3): undefined reference to `pcre_free'
/usr/app/godi-3.11/lib/ocaml/pkg-lib/pcre/libpcre_stubs.a(pcre_stubs.o):
In function `pcre_dealloc_regexp':
pcre_stubs.c:(.text+0x25): undefined reference to `pcre_free'
/usr/app/godi-3.11/lib/ocaml/pkg-lib/pcre/libpcre_stubs.a(pcre_stubs.o):
In function `pcre_config_match_limit_stub':
pcre_stubs.c:(.text+0xaf): undefined reference to `pcre_config'
/usr/app/godi-3.11/lib/ocaml/pkg-lib/pcre/libpcre_stubs.a(pcre_stubs.o):
In function `pcre_config_stackrecurse_stub':
pcre_stubs.c:(.text+0xdf): undefined reference to `pcre_config'
/usr/app/godi-3.11/lib/ocaml/pkg-lib/pcre/libpcre_stubs.a(pcre_stubs.o):
In function `pcre_config_link_size_stub':
pcre_stubs.c:(.text+0x10f): undefined reference to `pcre_config'
/usr/app/godi-3.11/lib/ocaml/pkg-lib/pcre/libpcre_stubs.a(pcre_stubs.o):
In function `pcre_config_newline_stub':
pcre_stubs.c:(.text+0x13f): undefined reference to `pcre_config'
/usr/app/godi-3.11/lib/ocaml/pkg-lib/pcre/libpcre_stubs.a(pcre_stubs.o):
In function `pcre_config_utf8_stub':
pcre_stubs.c:(.text+0x16c): undefined reference to `pcre_config'
/usr/app/godi-3.11/lib/ocaml/pkg-lib/pcre/libpcre_stubs.a(pcre_stubs.o):
In function `pcre_names_stub':
pcre_stubs.c:(.text+0x23a): undefined reference to `pcre_fullinfo'
pcre_stubs.c:(.text+0x25c): undefined reference to `pcre_fullinfo'
pcre_stubs.c:(.text+0x27e): undefined reference to `pcre_fullinfo'
/usr/app/godi-3.11/lib/ocaml/pkg-lib/pcre/libpcre_stubs.a(pcre_stubs.o):
In function `pcre_lastliteral_stub':
pcre_stubs.c:(.text+0x437): undefined reference to `pcre_fullinfo'
/usr/app/godi-3.11/lib/ocaml/pkg-lib/pcre/libpcre_stubs.a(pcre_stubs.o):
In function `pcre_firstbyte_stub':