使LibCurl与Visual Studio 2013配合使用 [英] Getting LibCurl to work with Visual Studio 2013
问题描述
我无法使LibCurl与Visual Studio 2013一起工作。我下载了当前版本(curl-7.33.0),并尝试按照我在此网站上找到的说明:
添加libcurl库并成功编译后,我现在得到此错误消息:
应用程序无法正确启动(0xc000007b )。单击确定关闭应用程序。
这里是我试图运行的示例代码:
#include< iostream>
#include< stdio.h>
#include< curl / curl.h>
int main(void)
{
CURL * curl;
CURLcode res;
curl = curl_easy_init();
if(curl){
curl_easy_setopt(curl,CURLOPT_URL,http://google.com);
res = curl_easy_perform(curl);
/ * always cleanup * /
curl_easy_cleanup(curl);
}
return 0;
}
我相信我已经让LibCurl与Visual Studio 2013合作了。持续性
虽然,花了几个小时试图解决这些错误消息,我有点犹豫,说一切都工作正常现在。这就是为什么我要对这个问题提供一个赏金,以获得清楚和简洁的指示关于获取LibCurl工作与Visual Studio 2013.
这个是我做的,让它工作:
-
首先,下载Win32 MSVC包这里: http://curl.haxx.se/download.html#Win32
为了这些说明,我们假设您下载到C :\LibCurl -
在Visual Studio中启动一个新项目。转到项目|项目属性| VC ++目录|包括目录|
将路径添加到下载的包中的include目录。 (C:\LibCurl\include) -
接下来,转到项目|项目属性|
将路径添加到lib目录。 -
然后,转到Project | Project Properties | Linker | Input | Additional Dependencies |
并添加 curllib.lib -
现在如果你编译一个测试程序,你可能会得到libsasl .dll缺失。您将需要下载此文件,并将其放在与您的构建相同的目录。
我使用7-Zip从 OpenLDAP for Windows 中提取 libsasl.dll 。 适用于Windows的OpenLDAP
这是我上面的测试代码的结果:
我会说在评论,但我缺乏点。
您不必将任何.dll复制到程序运行目录中。
转到项目|属性|配置属性和环境变量: PATH = $(ExecutablePath)$(LocalDebuggerEnvironment)
。
从现在起,项目|项目属性| VC ++目录|二进制中提到的任何目录中的所有.dll文件都应该可以使用,无需复制。
其余的就是你写的。
I am having trouble getting LibCurl to work with Visual Studio 2013. I downloaded the current version (curl-7.33.0) and tried following the instructions I found on this site: Using LibCurl with Visual 2010
But I can't find curllib.lib in the folder I downloaded. And I am still getting errors:
After searching the internet for more help. I now get these error messages. There appears to be a problem with linking to libcurl.lib?
This is what I have configured:
Inside /lib I have libcurl.lib and libcurl.dll
UPDATE
I downloaded this release for Win32 MSVC: http://curl.haxx.se/download.html#Win32 After adding the libcurl libraries and successfully compiling, I am now getting this error message:
The application was unable to start correctly (0xc000007b). Click OK to close the application.
Here is the sample code I am trying to run:
#include <iostream>
#include <stdio.h>
#include <curl/curl.h>
int main(void)
{
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if (curl) {
curl_easy_setopt(curl, CURLOPT_URL, "http://google.com");
res = curl_easy_perform(curl);
/* always cleanup */
curl_easy_cleanup(curl);
}
return 0;
}
FINAL UPDATE
I believe I have gotten LibCurl to work with Visual Studio 2013 now. Persistence ftw! Although, after spending hours trying to solve these error messages, I am a little hesitant at saying everything is working fine now. That is why I am putting a bounty on this question to get clear and concise instructions on getting LibCurl to work with Visual Studio 2013.
This is what I did to get it to work:
First, download the Win32 MSVC package here: http://curl.haxx.se/download.html#Win32 For these instructions sake, let's say you downloaded to C:\LibCurl
Start a new project in Visual Studio. Go to Project|Project Properties|VC++ Directories|Include Directories| Add the path to the include directory inside the downloaded package. (C:\LibCurl\include)
Next, go to Project|Project Properties|Linker|General|Additional Library Directories| Add the path to the lib directory. (Where curllib.dll is located)
Then, go to Project|Project Properties|Linker|Input|Additional Dependencies| And add curllib.lib
Now if you compile a test program, you will likely get the message saying libsasl.dll is missing. You will need to download this file and put it in the same directory as your build. I used 7-Zip to extract libsasl.dll from OpenLDAP for Windows. OpenLDAP for Windows
This is the result of my test code from above:
I would say that in a comment, but I am lacking in points.
You don't have to copy any .dll into your program run catalog.
Go to Project | Properties | Configuration Properties and in line Envrionment write: PATH=$(ExecutablePath)$(LocalDebuggerEnvironment)
.
From now on, all .dlls from any catalog you mention in Project|Project Properties|VC++ Directories|Binary should be usable without copying them.
The rest is exactly as you written.
这篇关于使LibCurl与Visual Studio 2013配合使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!