caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Gerd Stolpmann <info@gerd-stolpmann.de>
To: "Richard W.M. Jones" <rich@annexia.org>
Cc: Paul Steckler <steck@stecksoft.com>, caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Mixed static/dynamic linking of libraries
Date: Mon, 02 May 2011 14:40:39 +0200	[thread overview]
Message-ID: <1304340039.2630.70.camel@gps-desktop> (raw)
In-Reply-To: <20110502120039.GA26250@annexia.org>

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
> 



  reply	other threads:[~2011-05-02 12:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-02  6:49 Paul Steckler
2011-05-02 12:00 ` Richard W.M. Jones
2011-05-02 12:40   ` Gerd Stolpmann [this message]
2011-05-15 12:46 ` ygrek

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=1304340039.2630.70.camel@gps-desktop \
    --to=info@gerd-stolpmann.de \
    --cc=caml-list@yquem.inria.fr \
    --cc=rich@annexia.org \
    --cc=steck@stecksoft.com \
    /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;
as well as URLs for NNTP newsgroup(s).