From: Alan Falloon <alan.falloon@marseda.com>
To: caml-list@inria.fr
Subject: How can I convince ocamlbuild to link a library instead of object files?
Date: Wed, 17 Oct 2007 11:10:21 -0400 [thread overview]
Message-ID: <ff58m6$u8$1@ger.gmane.org> (raw)
[-- Attachment #1: Type: text/plain, Size: 960 bytes --]
I am working on a project in ocaml that has a number of libraries that
it depends on that are being concurrently developed.
I can easily set up ocamlbuild to build the binaries and the libraries,
however the binaries are always built from the object files that are
packed into the library even if I tell it to link in the library via a
plugin.
I have attached an interactive script (lightly edited for clarity). The
thing to notice is that when it links main.byte it still includes
hello.cmo and world.cmo even though they are in hw.cma. This works for
the bytecode linking, but its a disaster for native code.
Is there some way to remove the object files from the link line in the
plugin? or am I missing some trick? It doesn't matter if the library
sources are in a different directory, if its included (and it has to be
included or ocamlbuild won't build the lib) then ocamlbuild will find
the object files and use them.
Thanks,
Alan Falloon
[-- Attachment #2: ocamlbuild-lib-example --]
[-- Type: text/plain, Size: 1669 bytes --]
Script started on Wed Oct 17 10:55:12 2007
% ls
_tags hello.ml hw.mllib main.ml myocamlbuild.ml world.ml
% cat _tags
<main.*>: use_hw
% cat hello.ml
let hello () = Printf.printf "hello "
% cat world.ml
let world () = Printf.printf "world!\n"
% cat main.ml
let () = Hello.hello (); World.world ()
% cat myocamlbuild.ml
open Ocamlbuild_plugin;;
open Command;;
dispatch begin
function After_rules ->
flag ["ocaml"; "use_hw"; "link"; "byte"] (P "hw.cma");
flag ["ocaml"; "use_hw"; "link"; "native"] (P "hw.cmxa");
dep ["ocaml"; "use_hw"; "link"; "byte"] ["hw.cma"];
dep ["ocaml"; "use_hw"; "link"; "native"] ["hw.cmxa"]
| _ -> ()
end
% ocamlbuild -classic-display main.byte
ocamlopt.opt -I +ocamlbuild unix.cmxa ocamlbuildlib.cmxa myocamlbuild.ml ocamlbuild.cmx -o myocamlbuild
ocamldep.opt -modules main.ml > main.ml.depends
ocamldep.opt -modules hello.ml > hello.ml.depends
ocamldep.opt -modules world.ml > world.ml.depends
ocamlc.opt -c -o hello.cmo hello.ml
ocamlc.opt -c -o world.cmo world.ml
ocamlc.opt -c -o main.cmo main.ml
ocamlc.opt -a hello.cmo world.cmo -o hw.cma
ocamlc.opt hw.cma hello.cmo world.cmo main.cmo hw.cma -o main.byte
% ocamlbuild -classic-display main.native
ocamlopt.opt -c -o hello.cmx hello.ml
ocamlopt.opt -c -o world.cmx world.ml
ocamlopt.opt -c -o main.cmx main.ml
ocamlopt.opt -a hello.cmx world.cmx -o hw.cmxa
ocamlopt.opt hw.cmxa hello.cmx world.cmx main.cmx hw.cmxa -o main.native
+ ocamlopt.opt hw.cmxa hello.cmx world.cmx main.cmx hw.cmxa -o main.native
<lots of link errors...>
collect2: ld returned 1 exit status
Error during linking
Command exited with code 2.
%
Script done on Wed Oct 17 10:56:29 2007
next reply other threads:[~2007-10-17 15:11 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-17 15:10 Alan Falloon [this message]
2007-11-21 12:53 ` [Caml-list] " Nicolas Pouillard
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='ff58m6$u8$1@ger.gmane.org' \
--to=alan.falloon@marseda.com \
--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