cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Dynamic linking to libcurl on linux

From: Dan Fandrich <dan_at_coneharvesters.com>
Date: Mon, 29 Nov 2004 11:34:28 -0800

On Mon, Nov 29, 2004 at 09:05:09PM +0530, Arvind Sachdeva wrote:
> I am linking (not using dlopen) my program with libcurl.so, which is a
> symbolic link to libcurl.so.2 . I want my binary to run on most of the
> OS's. But I see some os's have libcurl.so.2 while others have
> libcurl.so.3. This becomes a sad situation because I get an error that
> Program failed to load while trying to look for liburl.so.2 which is
> a very sad situation, I dont want to relink my program for these other
> OS's. Is there a way my program works with almost all libcurl.so.x.

The reason there are two file names for the library is that the new one
breaks binary compatibility with the old one. In the general case, you
can't just load either one and expect it to work. Theoretically, the
newer version could have changed to require URLs to be specified in EBCDIC,
or renumbered the error codes and made them type double, or any other
far-reaching change that would make working with both types difficult to
do in your program.

However, in the case of libcurl moving from .2 to .3, the only BC break
in libcurl.so.3 was the removal of some deprecated functions, IIRC.
If you avoid using any of those symbols, you should be able to load
either library dynamically without needing any run-time change in your
program. Just try loading 'libcurl.so.3' and if it's not found, load
'libcurl.so.2' instead. Don't expect this to work for libcurl.so.4,
though...

> Can you point me to documents that explain waht is this 'x' thingy in
> libcurl.so.x ? If what I understand out of this scheme is true then
> while using this scheme how is the compatibility with lower versions
> maintained. There is concept of versioned symbols isnt that a better
> way of providing newer versions ?

Look at the "Versioning" section of the libtool info pages.

>>> Dan

-- 
http://www.MoveAnnouncer.com              The web change of address service
          Let webmasters know that your web site has moved
Received on 2004-11-29