Reputation: 703
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.
Upvotes: 10
Views: 3226
Reputation: 1578
Usually people get this error when they are trying to #include a library's header file with the library's "EXPORT" macro defined. curlpp must have some macro, usually found in code that looks like this:
#ifdef NATIVEDLL_EXPORTS
#define NATIVEDLL_API extern "C" __declspec(dllexport)
#else
#define NATIVEDLL_API __declspec(dllimport)
#endif
and you have the NATIVEDLL_EXPORTS defined in the preprocessor. Remove this definition. ppcurl won't be called "NATIVEDLL_EXPORTS", it will have some name of its own.
Upvotes: 0
Reputation: 33589
Addition to Piotr's answer: don't forget to build libcurl itself accordingly - dynamically or statically and define CURL_STATICLIB alongside CURLPP_STATICLIB (if building static version, of course). And on a sidenote: I absolutely didn't like CURLPP, it was hard to understand how to make it do what I need. You might want to use pure libcurl with your own wrapper.
Upvotes: 0
Reputation: 42425
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
Upvotes: 2