cURL / Mailing Lists / curl-library / Single Mail


Re: use libcurl source files directly rather than link with library

From: Daniel Stenberg <>
Date: Tue, 17 May 2011 11:41:08 +0200 (CEST)

On Mon, 16 May 2011, Tom Bishop, Wenlin Institute wrote:

> Is it possible to use libcurl by compiling its source files together with my
> application's source files, rather than first building libcurl as a library
> and then linking with the library?

Possible? Sure!

Wise? Not necessarily.

> My application runs on several platforms and uses several libraries.
> Building and linking with all the libraries on all the platforms is often
> problematic due to mismatches between 32-bit and 64-bit versions;
> cross-compiling from one platform to another; using shared versus static
> libraries; installing or distributing the libraries if they are shared;
> conflicts with different versions of the libraries that may already be
> installed; etc. I find it is often simpler and easier to include a library's
> C source files in my application's project or makefile.

Sorry, but none of that makes a lot of sense. Why can't you just put libcurl
in a separate directory and build that first exactly the way you want it, then
you build your app and link (statically) with the libcurl you just built. Then
you're not dependant on any mismatches, bad platforms, weird distributions or
anything. You have the full power to set it up exactly as you like it.

The bonus is that you're then building libcurl as it was made to get built so
you don't get a lot of extra head aches because of special requirements and

> (A great example of a library that is easy to use in this way is SQLite, for
> which you simply #include sqlite.h, and add sqlite.c to your project or
> makefile. Other libraries require dozens of files, but it's the same idea.)

I'm not at all convinced that's a particularly good idea for your average
library. I can't see any particular benefits for us to have libcurl optmized
for such a use.

> I've tried to figure out how to do it with libcurl, but so far the makefile
> is too complicated for me to understand;

Don't read the Makefile, read Just build all lib/*.c files.

> and lib/easy.c can't be compiled without defining various macros.

It includes its own headers so the macros and defines are there. Did you
forget to run configure first?

List admin:
Received on 2011-05-17