cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: vc++ still having problems

From: JB <curl_at_itpsg.com>
Date: Fri, 2 Sep 2005 08:58:29 -0600

> I have been using in windows as DLL and had no problems. After this mail I
> tried the static version and was able to make it work but need to make
some
> changes. I Used VC7 and have attached all the files used. I had setup
ready
> for Curl 7.13 so tried this using that.
>

OK, I downloaded 7.13.2 release source did nmake vc in its root and at least
that version compiles cleanly. It looks like nmake vc or vc-ssl in the link
step for curl.exe is leaving out CURL_STATICLIB in 7.14.0. Anyway, I saved
the proj you sent me, changed its include and lib path to point to the newly
built curl-7.13.2\include and curl-7.13.2\lib\release directories.

> The client application which used libcurl as static lib need to do the
> following
>
> 1 When curllib.lib is used directly we get bunch of linker errors like
this
>
> StaticTest error LNK2019: unresolved external symbol
> _imp__curl_global_cleanup referenced in function _main
>
> This is becos of
>
> #if (defined(WIN32) || defined(_WIN32)) && !defined(CURL_STATICLIB)
> #if defined (BUILDING_LIBCURL)
> #define CURL_EXTERN __declspec(dllexport)
> #else
> #define CURL_EXTERN __declspec(dllimport)
> #endif
> #else
> #define CURL_EXTERN
> #endif
>
>
> With the above declaration CURL_EXTERN will be declared as
> __declspec(dllimport). So add CURL_STATICLIB define to your client
> application to declare it as nothing.
>

Yeah, I figured that one out and already got this in mine as well.

> 2 curllib.lib uses two libraries Ws2_32.lib Winmm.lib. Since its static
you
> need to add this to your linker path.
>

Thanks to Jason, I was missing ws2_32.lib but got this in and was able to
compile and link at that point.

> 3 When no callback was set libcurl was crashing while trying to write the
> data to default handler. I set my own handler by calling
> curl_easy_setopt(curl,CURLOPT_WRITEFUNCTION,curlWriteData) and everything
> worked fine. Need to investigate why it crashed in default handler.
>
>
> I have attached the .vcproj for both my sample and libcurl. I have
attached
> test code also which you sent to test. Hope it helps.
>

Using the modified source you sent I am still getting the exact same
problem. Call stack is:

  NTDLL.DLL!77f9193c()
  NTDLL.DLL!77fb2a30()
  NTDLL.DLL!77fb1cff()
  NTDLL.DLL!77fa63b6()
  KERNEL32.DLL!7c58f7ba()
> msvcr71d.dll!_CrtIsValidHeapPointer(const void * pUserData=0x00932cd0)
Line 1807 C
  msvcr71d.dll!_free_dbg_lk(void * pUserData=0x00932cd0, int nBlockUse=1)
Line 1132 + 0x9 C
  msvcr71d.dll!_free_dbg(void * pUserData=0x00932cd0, int nBlockUse=1) Line
1070 + 0xd C
  msvcr71d.dll!free(void * pUserData=0x00932cd0) Line 1025 + 0xb C
  msvcr71d.dll!free(void * pUserData=0x00932cd0) Line 1025 + 0xb C
  StaticTest.exe!_Curl_destroy_thread_data() + 0x13 C
  StaticTest.exe!_Curl_wait_for_resolv() + 0x175 C
  StaticTest.exe!_Curl_follow() + 0x4cc C
  StaticTest.exe!_Curl_perform() + 0x40 C
  StaticTest.exe!_curl_easy_perform() + 0x66 C
  StaticTest.exe!main(int argc=1, char * * argv=0x00925aa8) Line 46 + 0xb
C++
  StaticTest.exe!mainCRTStartup() Line 398 + 0x11 C
  KERNEL32.DLL!7c598989()

It chokes right here in hostthre.c when calling free on tsd->hostname
void destroy_thread_sync_data(struct thread_sync_data * tsd)
{
  if (tsd->hostname) {
    free(tsd->hostname);

What the heck? Is there a vstudio service pack I'm missing or something?
I'm running vstudio .net 2003 on windows 2000 advanced server with latest
service pack and hotfixes. Maybe it is time to try this on winXP
Received on 2005-09-02