cURL / Mailing Lists / curl-library / Single Mail

curl-library

RE: vc++ still having problems

From: Seethaprasad <seetha_at_picorp.com>
Date: Fri, 2 Sep 2005 12:22:46 +0530

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.

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.

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

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.

Seethaprasad

-----Original Message-----
From: curl-library-bounces_at_cool.haxx.se
[mailto:curl-library-bounces_at_cool.haxx.se] On Behalf Of JB
Sent: Friday, September 02, 2005 5:10 AM
To: libcurl development
Subject: vc++ still having problems

Sorry, me again...thnx for taking time to read.

I have used curl binaries under linux for several years now and always been
very happy with it. Again, thank you to all those who've contributed. But
I have to say, I've been at this for a many days now and I am about to
abandon libcurl and find an alternative. I have never had this much trouble
getting a 3rd party lib into one of my projects.

Out of the box, the curl.exe does not even compile clean. nmake with any of
the targets that link curl.exe always fail with at least four unresolved
symbols starting with __imp__. The snapshot yeilds same results as released
version. I think that is great that there lots of windows users out there
using this but I am guessing the vast majority is using the dll. However, I
need the static lib and having a hell of a time getting it to work. If it's
on my end, ok, but someone somewhere must have an idea of what I am doing
wrong? I have even followed several documents and articles I've found on
the net also with no luck.

I am changing to lib directory and running nmake -f Makefile.vc6
cfg=debug-ssl
I've also tried the curllib.lib generated by the .dsw project (except
configuring it for static lib instead of dll) with no luck.

I created the simplest of simplest console applications consisting solely of
the code at bottom of this message and made sure it was configured to use
the same run time libs as the statically built libcurld.lib which appears to
be MSVCRTD.lib. Although I am still seeing:

warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use
/NODEFAULTLIB:library

I still get many many of these:
libcurld.lib(easy.obj) : error LNK2019: unresolved external symbol
__imp__WSACleanup_at_0 referenced in function _name-your-favorite-one
_name-your-favorite-one just means the function names vary...

code from console app:

#include "stdafx.h"
#include <curl/curl.h>
#include <iostream>
#include <string>

CURL *curl;
CURLcode res;
char errorBuffer[CURL_ERROR_SIZE];
std::string buffer;

int _tmain(int argc, _TCHAR* argv[])
{

 curl_global_init(CURL_GLOBAL_WIN32 | CURL_GLOBAL_SSL);

 curl = curl_easy_init();
 if (curl)
 {
  res = curl_easy_setopt(curl, CURLOPT_WRITEDATA, &buffer);
  if (res != CURLE_OK)
  {
   std::cout << "setopt: CURLOPT_WRITEDATA failed\n";
  }
  res = curl_easy_setopt(curl, CURLOPT_URL, "http://www.google.com/");
  if (res != CURLE_OK)
  {
   std::cout << "setopt: CURLOPT_URL failed\n";
  }
  res = curl_easy_perform(curl);
  if (res != CURLE_OK)
  {
   std::cout << "perform failed!\n";
  }
  curl_easy_cleanup(curl);
 } else {
  std::cout << "Apparently curl failed to initialize...\n";
 }
 curl_global_cleanup();
 return 0;
}

Received on 2005-09-02