Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using CurlPP with vs2008

I'm trying to build a C++ console app in VS2008 using the static curlpp library. The code - which is curlpp example 00 - is as follows:

#include "stdafx.h"


#include <curlpp/curlpp.hpp>
#include <curlpp/Easy.hpp>
#include <curlpp/Options.hpp>


using namespace curlpp::options;

int main(int, char **)
{
  try
  {

    // Our request to be sent.
    curlpp::Easy myRequest;

    // Set the URL.
    myRequest.setOpt<Url>("http://example.com");

    // Send request and get a result.
    // By default the result goes to standard output.
    myRequest.perform();
  }

  catch(curlpp::RuntimeError & e)
  {
    std::cout << e.what() << std::endl;
  }

  catch(curlpp::LogicError & e)
  {
    std::cout << e.what() << std::endl;
  }

  return 0;
}

I've downloaded the source and have my include path pointed to the source include files, but when I try and compile, I get a boatload of errors in the inline files of the type:

definition of dllimport function not allowed

Surely lots of folks have used curlpp with vs2008 and I'm missing something obvious.

like image 508
Jon Avatar asked May 15 '09 18:05

Jon


1 Answers

Take a look at \include\curlpp\internal\buildconfig.h file where there are the following macros defined

CURLPPAPI
CURLPP_INCLUDE_TEMPLATE_DEFINITIONS
CURLPP_TEMPLATE_EXPLICIT_INSTANTIATION

based on values of these three macros

CURLPP_STATICLIB
BUILDING_CURLPP
CURLPP_SELF_CONTAINED 

Read about them in README.win32 file and define above three macros accordingly.
In case you still have a problem let us know.

By the way; today I put current version of curlpp for downloading curlpp-current.2009.05.21

like image 137
Piotr Dobrogost Avatar answered Sep 19 '22 03:09

Piotr Dobrogost