From: Basile STARYNKEVITCH <basile@starynkevitch.net>
To: caml-list@inria.fr
Subject: [Caml-list] static linking behavior of Ocaml w.r.t Dbm
Date: Fri, 25 Jul 2003 10:37:06 +0200 [thread overview]
Message-ID: <16160.60466.231363.674311@hector.lesours> (raw)
Dear All,
(I'm BCC the poesia-devel list, since the problem was first identified
for compilation of POESIA monitor. See http://poesia.sourceforge.net
and http://www.poesia-filter.org for more)
on the Debian Sid systems I've got it is not possible to easily
compile *statically* a program using Dbm. Consider the following (self
contained but usable) test program:
################################################################
(* file testdbm.ml *)
let dbopt = ref (None : Dbm.t option);;
let keyref = ref "";;
let dbpathref = ref "";;
let get_db () = match !dbopt with
None -> failwith "no db"
| Some db -> db;;
let main () =
Arg.parse
[
"-C", Arg.String (fun path ->
let db = Dbm.opendbm path
[ Dbm.Dbm_create; Dbm.Dbm_rdwr ] 0o640
in
dbopt := (Some db);
dbpathref := path;
Printf.printf "created dbm %S\n" path),
"create a Dbm" ;
"-R", Arg.String (fun path ->
let db = Dbm.opendbm path
[ Dbm.Dbm_create; Dbm.Dbm_rdonly ] 0o640
in
dbopt := (Some db);
dbpathref := path;
Printf.printf "reading dbm %S\n" path),
"open a readonly Dbm" ;
"-W", Arg.String (fun path ->
let db = Dbm.opendbm path
[ Dbm.Dbm_create; Dbm.Dbm_rdonly ] 0o640
in
dbopt := (Some db);
dbpathref := path;
Printf.printf "writing (&reading) dbm %S\n" path),
"open a readwrite Dbm" ;
"-K", Arg.String (fun key ->
keyref := key),
"set the current key" ;
"-P", Arg.String (fun vals ->
Dbm.add (get_db ()) !keyref vals;
Printf.printf "put key=%S val=%S in dbm %S\n"
!keyref vals !dbpathref),
"put a value" ;
"-D", Arg.Unit (fun () ->
Dbm.remove (get_db ()) !keyref ;
Printf.printf "deleted key=%S in dbm %S\n"
!keyref !dbpathref),
"delete a value" ;
"-G", Arg.Unit (fun () ->
let vals = Dbm.find (get_db ()) !keyref in
Printf.printf "got key=%S val=%S in dbm %S\n"
!keyref vals !dbpathref),
"get a value" ;
"-A", Arg.Unit (fun () ->
Dbm.iter
(fun k v -> Printf.printf "has key=%S val=%S\n" k v)
(get_db ())),
"dump all bindings" ]
(fun arg -> failwith (" unexpected arg " ^ arg))
"testdbm" ;
match !dbopt with
None -> ()
| Some db -> Dbm.close db;;
Printexc.print main ();;
(* eof testdbm.ml *)
################################################################
Save the above in a file testdbm.ml; then run
/usr/bin/ocamlopt -cclib -static dbm.cmxa testdbm.ml -o testdbm
You get a lot of messages like
/usr/lib/gcc-lib/i386-linux/3.3.1/../../../libgdbm_compat.a(dbmopen.o)(.text+0xc6): In function `dbm_open':
: undefined reference to `gdbm_open'
/usr/lib/gcc-lib/i386-linux/3.3.1/../../../libgdbm_compat.a(dbmopen.o)(.text+0x135): In function `dbm_open':
Removing the -cclib -static or adding -cclib /usr/lib/libgdbm.a solves
the problem
I just got the latest Ocaml from CVS, compiled and installed it
/usr/local/bin/ocamlopt -v
The Objective Caml native-code compiler, version 3.07+beta 1
Standard library directory: /usr/local/lib/ocaml
and it does not exhibit the above problem.
I don't know if it is a problem of Debian packaging, or an Ocaml 3.06
problem solved in 3.07
As a temporary workaround across a bug in Ocaml 3.06 in Debian Sid
(and perhaps other distributions), I suggest to Poesia users to add
the required -cclib option to the OPTLIBS makefile variable.
--
Basile STARYNKEVITCH http://starynkevitch.net/Basile/
email: basile<at>starynkevitch<dot>net
aliases: basile<at>tunes<dot>org = bstarynk<at>nerim<dot>net
8, rue de la Faïencerie, 92340 Bourg La Reine, France
-------------------
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
reply other threads:[~2003-07-25 8:37 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=16160.60466.231363.674311@hector.lesours \
--to=basile@starynkevitch.net \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox