From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=AWL,SPF_FAIL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id BAFC6BC69 for ; Wed, 17 Oct 2007 17:11:47 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAGrCFUfAXQInh2dsb2JhbACOTgIBCAop X-IronPort-AV: E=Sophos;i="4.21,290,1188770400"; d="scan'208";a="3154208" Received: from concorde.inria.fr ([192.93.2.39]) by mail2-smtp-roc.national.inria.fr with ESMTP; 17 Oct 2007 17:11:48 +0200 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l9HFBZm2003458 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Wed, 17 Oct 2007 17:11:47 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAGrCFUdQW+UCh2dsb2JhbACOTgIBCAop X-IronPort-AV: E=Sophos;i="4.21,290,1188770400"; d="scan'208";a="3154207" Received: from main.gmane.org (HELO ciao.gmane.org) ([80.91.229.2]) by mail2-smtp-roc.national.inria.fr with ESMTP; 17 Oct 2007 17:11:47 +0200 Received: from list by ciao.gmane.org with local (Exim 4.43) id 1IiAYU-0001EF-VL for caml-list@inria.fr; Wed, 17 Oct 2007 15:11:30 +0000 Received: from dsl-207-112-67-87.tor.primus.ca ([207.112.67.87]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 17 Oct 2007 15:11:30 +0000 Received: from alan.falloon by dsl-207-112-67-87.tor.primus.ca with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 17 Oct 2007 15:11:30 +0000 X-Injected-Via-Gmane: http://gmane.org/ To: caml-list@inria.fr From: Alan Falloon Subject: How can I convince ocamlbuild to link a library instead of object files? Date: Wed, 17 Oct 2007 11:10:21 -0400 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------060802030603040407020603" X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: dsl-207-112-67-87.tor.primus.ca User-Agent: Thunderbird 1.5.0.13 (X11/20070824) Sender: news X-Miltered: at concorde with ID 47162627.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; ocaml:01 byte:01 cmo:01 cmo:01 bytecode:01 lib:01 printf:01 printf:01 ocaml:01 byte:01 cmxa:01 cmxa:01 ocamlopt:01 cmx:01 ocamldep:01 X-Attachments: name="ocamlbuild-lib-example" name="ocamlbuild-lib-example" This is a multi-part message in MIME format. --------------060802030603040407020603 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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 --------------060802030603040407020603 Content-Type: text/plain; name="ocamlbuild-lib-example" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="ocamlbuild-lib-example" Script started on Wed Oct 17 10:55:12 2007 % ls _tags hello.ml hw.mllib main.ml myocamlbuild.ml world.ml % cat _tags : 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 collect2: ld returned 1 exit status Error during linking Command exited with code 2. % Script done on Wed Oct 17 10:56:29 2007 --------------060802030603040407020603--