From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p42CesbV015304 for ; Mon, 2 May 2011 14:40:54 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AnECAH2lvk3U4xEKkWdsb2JhbACEUaFLFAEBAQEJCwsHFCWIcachj3iBKoNVgQEEiTuJV4oL X-IronPort-AV: E=Sophos;i="4.64,302,1301868000"; d="scan'208";a="82151070" Received: from moutng.kundenserver.de ([212.227.17.10]) by mail3-smtp-sop.national.inria.fr with ESMTP; 02 May 2011 14:40:49 +0200 Received: from office1.lan.sumadev.de (dslb-094-219-219-157.pools.arcor-ip.net [94.219.219.157]) by mrelayeu.kundenserver.de (node=mrbap1) with ESMTP (Nemesis) id 0LqWAb-1PdR4y1aT3-00eRO9; Mon, 02 May 2011 14:40:41 +0200 Received: from [192.168.0.33] (dslb-084-058-030-201.pools.arcor-ip.net [84.58.30.201]) by office1.lan.sumadev.de (Postfix) with ESMTPSA id C4E3F5F701; Mon, 2 May 2011 14:40:40 +0200 (CEST) From: Gerd Stolpmann To: "Richard W.M. Jones" Cc: Paul Steckler , caml-list@yquem.inria.fr In-Reply-To: <20110502120039.GA26250@annexia.org> References: <20110502120039.GA26250@annexia.org> Content-Type: text/plain; charset="UTF-8" Date: Mon, 02 May 2011 14:40:39 +0200 Message-ID: <1304340039.2630.70.camel@gps-desktop> Mime-Version: 1.0 X-Mailer: Evolution 2.28.3 Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:dKpRFSHXJSXln9suC2GH/bUqeiYZR3/jiDQgwHto9TY x8tG2O/TDPQtun4nDXdhJFi40gwRxJDnsEVJiD2GXy5V4Y3Zaw 7AOiXk8102RqJTdH78XlcsGMu1s+KlBjf9YcotEE492BDu7dbz AV/ANYKr6f2SK/kwzoDCLhaC9XRRH2/8hPt4SbzZ874IRAOOdF W58/JWkvQ2tWHZTm9ljcw== Subject: Re: [Caml-list] Mixed static/dynamic linking of libraries Am Montag, den 02.05.2011, 13:00 +0100 schrieb Richard W.M. Jones: > On Mon, May 02, 2011 at 04:49:03PM +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. > > I've tried various combinations > > of -cclib -static and -cclib -Bdynamic, to no avail. If I use the arguments > > > > -cclib -static -cclib -lsqlite3 > > > > the linker appears to find libsqlite3.a, but the linker then tries to > > statically link every other library > > used by my application. That's so even if I follow the above by > > -cclib -Bdynamic. > > > > Is there a way to mix static and dynamic libraries using ocamlfind? > > Have you tried naming the library explicitly, eg: > > -cclib /usr/lib/libsqlite3.a You could also try -cclib -l:libsqlite3.a According to ld docs, the colon prevents the automatic name translation that results in preferring libsqlite3.so. However, I don't think this will be successful. The ocamlfind/ocamlopt/gcc/ld chain will generate a normal -lsqlite3 nevertheless, and so far I've tried it, this takes precedence. What you can try is to copy libsqlite3.a to a private directory p, and use -ccopt -Lp to add it to the library search path. Also note that static linking is more sensitive to the order of the linked libraries. As more or less everybody is using dynamic linking, these problem often remain unnoticed. Gerd > Rich. > > -- > Richard Jones > Red Hat >