From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p4FCluPG023233 for ; Sun, 15 May 2011 14:47:56 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AtUBAOfKz03RVdY0kGdsb2JhbACmDQgUAQEBAQkJDQcUBCGIcKRVjBqCNYNlN4hiAQEDBoYTBIZKiUeFQIVFO4M4 X-IronPort-AV: E=Sophos;i="4.64,369,1301868000"; d="scan'208";a="108596283" Received: from mail-bw0-f52.google.com ([209.85.214.52]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 15 May 2011 14:47:51 +0200 Received: by bwj24 with SMTP id 24so5544448bwj.39 for ; Sun, 15 May 2011 05:47:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:date:from:to:cc:subject:message-id:in-reply-to :references:x-mailer:mime-version:content-type :content-transfer-encoding; bh=mw+F00aZUhR0Zpu8rVoA6Jqbep77DK8uhKc3wHALwXQ=; b=H8ZBxP7Q5jBppSi1qBeocKHQ2l3nAbL/jYnVvK0YPYux3qTU3iROne2c4KJwnXZ5Lk U4mAUFjXIi+KAAuK2QH+Gpl2qP7OH6O17abUm4H47kVuOMntL3RV8jKja9wL5A1rVl+2 IUF6Di4mnfYXTquEJ/9Vk54SlAcwPYQIoqDCw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:in-reply-to:references:x-mailer :mime-version:content-type:content-transfer-encoding; b=BU3H1zb3zihufiCEbsq5jMO0FlkRR8S0u9n9wJFUYQETzB5gH6CTRaAuI1RaTe78P6 XsX4D8k0keR8rb64vZCb0KCTMuA6T+i1fOY/QpjPILG47DHYb5v0V/IUg1abdoEnuwfv bU41CXcP7Xg4WtOqzHcGX9rGPtXDb7D1D/9CM= Received: by 10.204.114.144 with SMTP id e16mr3237146bkq.119.1305463621142; Sun, 15 May 2011 05:47:01 -0700 (PDT) Received: from lemon.local.tld (37-166-133-95.pool.ukrtel.net [95.133.166.37]) by mx.google.com with ESMTPS id x6sm2409999bkv.12.2011.05.15.05.46.57 (version=SSLv3 cipher=OTHER); Sun, 15 May 2011 05:46:59 -0700 (PDT) Date: Sun, 15 May 2011 15:46:30 +0300 From: ygrek To: Paul Steckler Cc: caml-list@yquem.inria.fr Message-Id: <20110515154630.07910bb1.ygrekheretix@gmail.com> In-Reply-To: References: X-Mailer: Sylpheed 3.0.2 (GTK+ 2.20.1; i486-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Caml-list] Mixed static/dynamic linking of libraries On Mon, 2 May 2011 16:49:03 +1000 Paul Steckler wrote: > I want to statically link a library (libsqlite3.a) with my OCaml > application, but allow other > libraries to link dynamically. I'm building using ocamlfind on Linux. The ultimate goal is to get `-Wl,-Bstatic -lsqlite3 -Wl,-Bdynamic` in the final invocation of gcc when linking your binary (without any other references to sqlite3 on command-line). Possible approaches : 1) patch the build system of ocaml-sqlite3 so that it embeds the above flags into cmxa 2) insert linker instructions with -ccopt's around the reference to sqlite3.cmxa when linking your application - IIRC this didn't work for me because ocamlopt reorders command-line arguments when passing them to gcc in some incomprehensible way. 3) use -noautolink and specify the above flags as single -ccopt (and do this for all cma's with embedded options). (1) looks most simple to me and ideally ocamlopt could allow embedding several sets of options into cma and choosing them at final link with some option/tags, then all libraries could easily embed two command-lines - for static and dynamic linking. -- ygrek http://ygrek.org.ua