cURL / Mailing Lists / curl-library / Single Mail

curl-library

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

From: Tom Bishop, Wenlin Institute <tangmu_at_wenlin.com>
Date: Tue, 17 May 2011 10:45:25 -0400

On May 17, 2011, at 5:41 AM, Daniel Stenberg wrote:

...
> 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.

Because I don't know how. I'll try to learn. In my experience with other libraries, it can be difficult to produce the needed architecture (32-bit versus 64-bit, PowerPC versus Intel, static versus shared, etc.), especially when cross-compiling; and it can be a lot easier to add the source files to my own project. It's not clear why that would be unwise. It has worked well with other libraries.

> 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 ideas.

Sometimes there's more than one way to do something. I thought there might be more than one way to use libcurl. Sorry if my question was offensive.

> Don't read the Makefile, read Makefile.am.

Thanks, I will.

> 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?

No, that was the first thing I did. After downloading libcurl 7.21.6 on Mac OS 10.6.7, I did this:

./configure
make
sudo make install

Then:

curl-config --version
7.19.4

I figured that the newer libcurl (7.21.6) must have been installed in a different location from the one that came with OS X (7.19.4), so I did this:

curl-config --prefix
/usr

And I reinstalled like this:

./configure --prefix=/usr
make
sudo make install

Now the version was reported as 7.21.6. However, my program (by #include <curl/curl.h>) still appeared to be using the old curl.h here:

/Developer/SDKs/MacOSX10.4u.sdk/usr/include/curl

So I deleted that entire folder, and changed

#include <curl/curl.h>

to

#include "../curl/include/curl.h"

But then got this:

error: size of array ‘__curl_rule_01__’ is negative

I'm guessing this might be a 32-bit versus 64-bit conflict. I'll study the documentation further and try to make sure I'm building a 32-bit libcurl (since we're currently using Carbon on OS X). We also need versions for MS-Windows (cross-compiled from Mac OS as well as directly compiled on Windows), and Linux, and WinCE; and static libraries would be much preferable to shared.

Am I really foolish to think it would be easier (for dummies like myself) if we could simply add libcurl.c (or curl/lib/*.c) to our project?

I've tried this:

cc -Wall simple.c lib/easy.c

The result is:

In file included from lib/setup.h:583,
                 from lib/easy.c:23:
lib/setup_once.h:89: error: redefinition of ‘struct timeval’

Evidently HAVE_STRUCT_TIMEVAL needs to be defined. So I tried:

cc -Wall -DHAVE_STRUCT_TIMEVAL simple.c lib/easy.c

The result is:

In file included from lib/setup.h:583,
                 from lib/easy.c:23:
lib/setup_once.h:154: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘Missing_definition_of_macro_sread’

This is what I meant by "lib/easy.c can't be compiled without defining various macros" (and yes, this is after running ./configure).

libcurl is a great library, and I really appreciate it. For our cross-platform development purposes I was just hoping we might be able to simplify the process of configuration, installation, and linking.

Best wishes,

Tom

文林 Wenlin Institute, Inc. Software for Learning Chinese
E-mail: wenlin@wenlin.com Web: http://www.wenlin.com
Telephone: 1-877-4-WENLIN (1-877-493-6546)

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2011-05-17