cURL / Mailing Lists / curl-library / Single Mail

curl-library

AW: help on libcurl (Win32 - Generic) with Borland C++ Builder

From: Goettlicher Harald (AA-DG/ESW4) <Harald.Goettlicher_at_de.bosch.com>
Date: Wed, 25 Jul 2007 14:23:34 +0200

Hi Cheng-Lin Yang,

i also use libcurl (Win32 - Generic) with Borland C++ Builder.

I build the library myself.
This is really easy and might be more stable, no DLL needs to be delivered and you have the full source code control over your project.

I just added a new project node libcurl.lib with all the .C-Sourcecode.
In the node options i set the Conditionals "WIN32;_WINDOWS;_USRDLL;BUILDING_LIBCURL;_DEBUG" and the include path.
Besides that, nothing special was required.
The lib is linked to the EXE.

After that, you can just use curl the easiest way, without getting function pointers:

#include <curl/types.h>
#include <curl/easy.h>

(...)

   CURL *curl;

   // init curl handler
   curl = curl_easy_init();

   // curl handler valid?
   if(curl)
   {

Regards,

  Harald

-----Ursprüngliche Nachricht-----
Von: curl-library-bounces_at_cool.haxx.se [mailto:curl-library-bounces_at_cool.haxx.se] Im Auftrag von Cheng-Lin Yang
Gesendet: Mittwoch, 18. Juli 2007 20:48
An: andy
Cc: curl-library
Betreff: Re: help on libcurl (Win32 - Generic) with Borland C++ Builder
Wichtigkeit: Hoch

Hi Andre,
I finally tried out the solution. I post a successfully work source code
in my blog. Hope this can help others who use C++ Builder with libcurl.

Example code:
http://exodus.cs.ccu.edu.tw/~yuwen/NUBlog/

Regards,
Cheng-Lin Yang
-----Original message-----
From:Andre Guibert de Bruet <andy_at_siliconlandmark.com>
To:yuwen_at_exodus.cs.ccu.edu.tw
Cc:libcurl development <curl-library_at_cool.haxx.se>
Date:Wed, 18 Jul 2007 09:00:30 -0400
Subject:Re: help on libcurl (Win32 - Generic) with Borland C++ Builder

On Jul 18, 2007, at 8:55 AM, Andre Guibert de Bruet wrote:
> On Jul 18, 2007, at 7:38 AM, Cheng-Lin Yang wrote:
>> But I don't know how to use the function in liburl-4.dll.(I know
>> I should use GerProcAddress to do so, but is there any example?)
>> Can someone here help me on this? Thanks. :)
>>
>> My code:
>> if( ( cl = LoadLibrary( "c:\\libcurl-4.dll" ) ) == NULL ){
>> MessageBox(NULL, "I can't load libcurl","DingDing", 0);
>> return;
>> }
>>
>> I_dont_know_how_to_get = GetProcAddress(cl, "curl_easy_init" );
>
> I strongly suggest you use the import library and not deal with the
> mess of assigning the right function pointer for each curl easy
> function. Just in case you decide not to, here is an example I have
> put together from an unrelated project (Names have been sanitized,
> of course ;-) ):
>
> typedef char *(*FNGETSTRING)(int);
>
> void dosomethinguseful()
> {
> char *blah;
> FNGETSTRING foo;
>
> ...
>
> foo = (FNGETSTRING) GetProcAddress(hDLL /* From LoadLibrary */,
> "foo");
> blah = foo(1); /* you are calling the GetProcAddress'ed function */
>
> ...
> }

In my example, I have not checked the return value of GetProcAddress
for clarity. The official MSDN documentation shows how to do this:
http://msdn2.microsoft.com/en-us/library/64tkc9y5(vs.71).aspx

Cheers,

/* Andre Guibert de Bruet * 436f 6465 2070 6f65 742e 2042 6974 206a */
/* Code poet / Sysadmin * 6f63 6b65 792e 2053 7973 4164 6d69 6e2e */
/* GSM: +1 734 846 8758 * 2055 4e49 5820 736c 6575 7468 2e00 0000 */
/* WWW: siliconlandmark.com * C/C++, Java, Perl, PHP, SQL, XHTML, XML */
Received on 2007-07-25