cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: portability with programs using libcurl

From: Tor Arntsen <tor_at_spacetec.no>
Date: Wed, 22 Oct 2003 10:04:36 +0200

On Oct 22, 4:04, "Jay" wrote:
>hi, i am currently coding a program in C that uses libcurl. On the =
>FreeBSD-UNIX system that i coded the program it works like a treat, but =
>the system has libcurl installed, with the libraries in the usual =
>directories, "/usr/local/lib/" and the headers in the usual directory =
>etc. I now wish to port my program to system that don't have libcurl =
>installed by default. I distributed the curl libs with my program and =
>compiled with -L./libs/ -lcurl and the program compiled perfectly no =
>errors (using gcc). I also included the headers into my program. When =
>i come to executing the binary output, i get the following. =
>/usr/libexec/ld-elf.so.1: Shared object "libcurl.so.2" not found, =
>however, if i set the environment variable LD_LIBRARY_PATH in the shell =
>to the ./libs/ which contains the libcurl libs, the program executes as =
>it should. Is there something i can do so that when someone wants to =
>use it on a system that doesn't have libcurl, they don't have to do =
>LD_LIBRARY_PATH ./libs/ etc.

Link statically, i.e. add -static to the link flags. That should work,
provided that the curl installation also included libcurl.a
-static will link all libs statically of course, including libc. That is
sometimes preferable, particularly when you can't guarantee that the
target system uses the same version of libc as you do. If, on the other
hand, only libcurl is of concern, then don't use -static but instead
add /usr/local/lib/libcurl.a directly to the list of files to be linked,
instead of using -lcurl. The latter method is also easier in case of
graphical applications, as linking the X11 libraries statically can
sometimes be problematic (and creates a huge executable as well).

-Tor

-------------------------------------------------------
This SF.net email is sponsored by OSDN developer relations
Here's your chance to show off your extensive product knowledge
We want to know what you know. Tell us and you have a chance to win $100
http://www.zoomerang.com/survey.zgi?HRPT1X3RYQNC5V4MLNSV3E54
Received on 2003-10-22