libcurl - 找不到过程入口点CreateFile2

时间:2014-07-29 14:40:03

标签: c++ visual-studio-2012 curl libcurl

我有一个Visual Studio 2012 C ++项目。我通过右键单击我的项目并选择Manage NuGet Packages安装了libcurl。

我正在尝试运行以下简单程序:

#include <stdio.h>
#include <curl\curl.h>

int main(void)
{
    CURL *curl;
    CURLcode res;

    curl_global_init(CURL_GLOBAL_DEFAULT);

    curl = curl_easy_init();
    if(curl)
    {
        //I will do something
    }

  return 0;
}

当我运行它时,我收到以下错误:

enter image description here

此解决方案:Calling any cURL function results in "entry point not found" when executing the program向我指出了这个解决方案:Using the Windows 8 SDK to compile for Windows 7告诉我从 Visual Studio 2012(v110)更改我的平台工具集 Visual Studio 2012 - Windows XP(v110_xp)

但我仍然得到同样的错误。

任何人都知道如何解决这个问题?

1 个答案:

答案 0 :(得分:2)

使用默认的“v110”/“v120”工具集使用Visual Studio 2012/2013构建时,您使用的是Windows 8.x SDK。要支持Windows 7,您只需设置预处理器定义_WIN32_WINNT = 0x0601即表示支持Windows 7或更高版本,而不是默认的0x0602或0x0603,表示支持Windows 8或更高版本。

请参阅MSDN

如果您更改为“v110_xp”/“v120_xp”tooslet,那么您使用的是Windows 7.1A SDK,因为Windows 8.x SDK无法支持Windows XP。如果您需要Windows XP支持,请将_WIN32_WINNT设置为0x0501。通常,您不需要使用“v110_xp”/“v120_xp”工具集来定位Windows 7。

这里更基本的问题是你可能根本没有构建cURL代码,因为你正在使用NuGet。

首先尝试设置_WIN32_WINNT设置,以查看NuGet包是否构建为支持低级Win32桌面应用程序。否则,NuGet与.libs一起发布,仅为Windows 8.x构建兼容性 - 这需要BTW在Windows应用商店应用而不是Win32桌面应用中使用它。您也可以尝试直接获取库并自己从原始项目网站http://curl.haxx.se/

构建它