Thanks a lot,  Dan. 

-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of Dan Fandrich
Sent: 2010年8月18日 14:29
To: [email protected]
Subject: Re: trying to link libcurl.so.4.2.0 directly in executable *.x

On Wed, Aug 18, 2010 at 11:34:18AM +0800, CHEN Xiaolei A wrote:
>    After I succeeding in compiling libcurl-7.21.0, the "lib" directory 
> lists as
> follow:
>   
>   -rw-r--r--   1 someone bjumts   1718756 Jul  1 17:42 libcurl.a
>   -rwxr-xr-x   1 someone bjumts      1166 Jul  1 17:42 libcurl.la
>   lrwxrwxrwx   1 someone bjumts        16 Jul  1 17:42 libcurl.so ->
> libcurl.so.4.2.0
>   lrwxrwxrwx   1 someone bjumts        16 Jul  1 17:42 libcurl.so.4 ->
> libcurl.so.4.2.0
>   -rwxr-xr-x   1 someone bjumts   1384988 Jul  1 17:42 libcurl.so.4.2.0
>   drwxr-xr-x   2 someone bjumts      4096 Jul  1 17:42 pkgconfig
> 
>  And under my design environment, I only use actual dynamic lib 
> (libcurl.so.4.2.0). I wrote a demo program, it can compile and link 
> successfully.
> 
> But before executing it, I use "ldd" command, it displays as follow:
>         > ldd FTPSession.x
>         libcurl.so.4 =>  (file not found)
>         libssh2.so.1 =>  (file not found)
>         libldap.so.5 =>  /usr/lib/libldap.so.5
>         librt.so.1 =>    /lib/librt.so.1
>         ......
> so when the program is begin execution, the name it want to find to 
> load dynamic lib is libcurl.so.4 -it's a symbol link refer to actual 
> dynamic lib (libcurl.so.4.2.0). But I don't need that, I hope the name 
> it want to find is libcurl.so.4.2.0.
> 
> My question is:
> 
> 1) What should  I do? If I need only actual dynamic 
> lib(libcurl.so.4.2.0) after compiling and installing, and when 
> executing a program, it can find actual dynamic lib name(libcurl.so.4.2.0), 
> not the symbol link libcurl.so.4?

When you link against libcurl, the linker uses the SONAME that's built-in to 
the .so file to know what to link to at run-time. The SONAME is libcurl.so.4, 
which is the most general name that by convention maintains binary 
compatibility in future releases.  You might be able to work some trickery with 
linker flags to use a different name, like libcurl.so.4.2.0, but why? If you 
ever want to upgrade libcurl to a new release to fix a security problem or bug, 
the new name is guaranteed to be different (e.g.
libcurl.so.4.2.1) and your program will fail to run.  If you insist on having 
no hard or symbolic links to the library, you'd probably be better off calling 
the library file libcurl.so.4 instead of libcurl.so.4.2.0.
If you are never going to upgrade libcurl without also upgrading the 
application, then just statically link it instead.

> 2) As we known, libcurl compiling is depending on libssh2, so for my 
> question 1), Is there any change when compiling libssh2?

The libcurl.so.4.2.0 dynamic library itself calls upon the SONAME of libssh2, 
which is libssh2.so.1. So you're going to encounter the same issue there if you 
don't want any links to libraries.

> 3) Does libcurl provide some interfaces to download a whole directory 
> recursively from a FTP server?

Recent versions of libcurl support CURLOPT_WILDCARDMATCH that may do what you 
want. Otherwise, you'll have to have the directory recursion logic in the app.

>>> Dan
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Reply via email to