使用CurlPP和vs2008

Jon*_*Jon 10 c++ curl visual-studio-2008 curlpp

我正在尝试使用静态curlpp库在VS2008中构建一个C++控制台应用程序.代码 - 例如curlpp示例00 - 如下:

#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;
}
Run Code Online (Sandbox Code Playgroud)

我已经下载了源代码,并且我的include路径指向了源包含文件,但是当我尝试编译时,我在类型的内联文件中遇到了大量错误:

不允许定义dllimport函数

肯定有很多人使用curlpp和vs2008,我错过了一些明显的东西.

Mac*_*ker 0

通常,当人们尝试 #include 定义了库的“EXPORT”宏的库的头文件时,会出现此错误。curlpp 必须有一些宏,通常在如下代码中找到:

#ifdef NATIVEDLL_EXPORTS
#define NATIVEDLL_API extern "C" __declspec(dllexport)
#else
#define NATIVEDLL_API __declspec(dllimport)
#endif
Run Code Online (Sandbox Code Playgroud)

并且您已在预处理器中定义了 NATIVEDLL_EXPORTS。删除这个定义。ppcurl 不会被称为“NATIVEDLL_EXPORTS”,它将有自己的名称。