cURL with Visual Studio 2013(cURL 与 Visual Studio 2013)
问题描述
所以我将 cURL 作为一个非常好的库一起出现,并且在 OSX 中工作得很好.但是现在在 Windows 上,我在准备这个库时遇到了很大的麻烦.我现在用谷歌搜索了大约 2 天,并尝试了十几种(详细)不同的方法来准备这个.根本没有任何成功.
So i have came along with cURL as a very nice library and working very fine in OSX. But on windows now i have got big troubles with getting ready with this library. I googled now for about 2 days and tried over a dozen (in detail) different ways to get this ready. Without any success at all.
以下是我基本上尝试过的一些方法:
Here are some ways I basically tried:
- 直接下载:这里的问题已经从正确的下载开始.官方下载页面非常混乱,所以我考虑了这个cURL 下载向导">libcurl 开发",它给了我一个版本,我应该能够将它包含到任何项目中.但究竟如何包含它呢?在任何说明中,它都会引导我进入我什至没有的目录.几乎总是提到这个curllib.lib".我在那个下载页面上下载了大约 6 个不同的版本,其中没有一个有这个文件.(例如参见此说明)
- Git + CMake:作为上述链接的解决方案,建议在此使用 git clone.我在那里做了所有的说明,并且只用警告生成了项目.但这里也说:
构建安装目标后,您会在 C:curl.vc12 中找到 bin/include/lib 文件夹
好吧,我并没有真正理解他的构建安装目标"的意思,我只是构建整个项目地图.编译正常(115 成功,0 失败,2 跳过).但是现在 C:curl.vc12 不存在.在编译之前我必须预先设置什么?
- NuGet:这个想法再次来自第 (1) 点中的链接,这是使用 NuGet 的不同解决方案.
用Successfully added 'curl 7.30.0.2' to test.
看起来也不错,但是编译simple.c
会导致一堆unresolved external symbol
链接器错误.但是提供了一个解决方案:
确保在项目属性的 Visual C++ 目录下指定包含目录和 lib 目录.
所以在Project >属性>VC++ 属性 >包括目录"
和
Project >属性>VC++ 属性 >库目录"
以及Project >C/C++ >一般 >附加包含目录"
和Project >链接器>一般 >附加库目录"
我拼命地从我的项目文件夹中添加了 packages 路径.
如说明中所述,我将libcurl.lib;libeay32.lib;ssleay32.lib;Ws2_32.lib;libssh2.lib;zlib.lib;wldap32.lib;
添加到Project >链接器>输入>其他依赖项"
.
所有这些都完成了,unresolved external symbol
错误消失了!因此,我只收到一个错误提示cannot open file 'libcurl.lib'
.我可以在这里做什么?
- The direct Download: The problem here already starts with the right download. The official download page is pretty confusing, so i considered this "cURL Download Wizard" > "libcurl development" which gives me a version, that i should be able to include into any project. But how exactly to include it? In ANY instructions out there it leads me to directories i dont even have. Almost always this "curllib.lib" is mentioned. I downloaded about 6 different versions on that downloadpage, in none of them there is this file. (See for example this instruction)
- Git + CMake: As a solution on the aboves Link there is suggested to use git clone on this. I did all the instructions there and also get the Projects generated with just warnings. But here it says as well:
After building install target, your will find bin/include/lib folders in C:curl.vc12
Well, i did not really get his point of "build install target", i just build the entire project map as it comes. Compiles fine (115 succeeded, 0 failed, 2 skipped). But now C:curl.vc12 is not there. What do i have to pre-setup before compiling this?
- NuGet: The idea comes from the link in point (1) again, a different solution with NuGet.
WithSuccessfully added 'curl 7.30.0.2' to test.
it also seemed nice, but compilingsimple.c
leads to a bunch ofunresolved external symbol
linker errors. But a solution is provided:
Make sure the include directory and lib directory are specified under the Visual C++ directories in project properties.
So inProject > Properties > VC++ Properties > "Include Directories"
and
Project > Properties > VC++ Properties > "Library Directories"
as well as inProject > C/C++ > General > "Additional Include Directories"
and inProject > Linker > General > "Additional Library Directories"
I desperately added the packages path from my project folder.
As mentioned in the instructions, I addedlibcurl.lib;libeay32.lib;ssleay32.lib;Ws2_32.lib;libssh2.lib;zlib.lib;wldap32.lib;
toProject > Linker > Input > "Additional Dependencies"
.
All that done, theunresolved external symbol
errors are gone! Therefore I get just one error sayingcannot open file 'libcurl.lib'
. What can I do here?
我对这一切都很陌生.但我现在非常努力地让它最终发挥作用.那么我能做什么呢?
我使用 Visual Studio 2013 社区版.当前最新版本的 cURL 是 7.42.1
.非常欢迎任何帮助!
I am pretty new to all that. But I am trying really hard now to get this finally to work. So what can I do?
I work with Visual Studio 2013 Community Edition. The currently most recent version of cURL is 7.42.1
.
Any help is highly welcome!
推荐答案
自己有问题,现在终于搞定了.我从官方网站下载了curl-7.42.1.zip.在存档中,您会找到源代码和 winbuild/BUILD.WINDOWS.txt,其中基本上包含我遵循的说明.我假设它已经解压缩到 C:curl-7.42.1.
Had problems myself, finally got it working now. I downloaded curl-7.42.1.zip from the official website. Within the archive you'll find the source code and winbuild/BUILD.WINDOWS.txt, which basically contains the instructions I followed. I'll assume that it has been unzipped to C:curl-7.42.1.
打开 Visual Studio 命令提示符 位于
C:Program Files (x86)Microsoft Visual Studio 12.0Common7ToolsShortcuts
C:Program Files (x86)Microsoft Visual Studio 12.0Common7ToolsShortcuts
这会自动设置使用编译器等 Visual Studio 工具所需的环境变量.然后移动到winbuild目录并调用
This automatically sets the environment variables needed to use Visual Studio tools like the compiler. Then move to the winbuild directory and call
nmake/f Makefile.vc mode=dll
nmake /f Makefile.vc mode=dll
如我上面提到的文本文件中所述.
as described in the text file I mentioned above.
这将创建目录
C:curl-7.42.1uildslibcurl-vc-x86-release-dll-ipv6-sspi-winssl
C:curl-7.42.1uildslibcurl-vc-x86-release-dll-ipv6-sspi-winssl
包含 libcurl.dll、libcurl.lib 和必要的头文件.我们把它重命名为 C:curl-7.42.1uilds
elease
:'D
containing libcurl.dll, libcurl.lib and the necessary header files. Let's rename it to C:curl-7.42.1uilds
elease
:'D
- 然后打开您的项目.
- 打开项目的属性.
- 确保选择 Release 作为配置(左上角)!
- 导航到
VC++ 目录 >包含目录
并添加C:curl-7.42.1uilds eleaseinclude
- 将
C:curl-7.42.1uilds eleaselib
添加到VC++ 目录 >库目录
. - 转到
链接器>输入>附加依赖项
并添加libcurl.lib
. - 最后将
C:curl-7.42.1uilds eleaseinlibcurl.dll
复制到你的项目文件夹中.
- Then open your project.
- Open your project's properties.
- Make sure you choose Release as configuration (top left corner)!
- Navigate to
VC++ Directories > Include directories
and addC:curl-7.42.1uilds eleaseinclude
- Add
C:curl-7.42.1uilds eleaselib
toVC++ Directories > Library directories
. - Go to
Linker > Input > Additional Dependencies
and addlibcurl.lib
. - Finally copy
C:curl-7.42.1uilds eleaseinlibcurl.dll
to your project folder.
这应该可以解决问题!:D 如果你想在调试模式下使用 cURL,你几乎可以这样做,使用 nmake/f Makefile.vc mode=dll debug=yes
重新编译,进入你的项目的属性,添加新的创建目录路径(将 libcurl.lib 更改为 libcurl_debug.lib),您应该完成了.
That should do the trick! :D If you want to use cURL in debug mode, you can do almost the same, recompile using nmake /f Makefile.vc mode=dll debug=yes
, go to your project's properties, add the newly created directory paths (changing libcurl.lib to libcurl_debug.lib) and you should be done.
这篇关于cURL 与 Visual Studio 2013的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:cURL 与 Visual Studio 2013
基础教程推荐
- 设计字符串本地化的最佳方法 2022-01-01
- 什么是T&&(双与号)在 C++11 中是什么意思? 2022-11-04
- 调用std::Package_TASK::Get_Future()时可能出现争用情况 2022-12-17
- C++ 标准:取消引用 NULL 指针以获取引用? 2021-01-01
- 您如何将 CreateThread 用于属于类成员的函数? 2021-01-01
- 如何在 C++ 中处理或避免堆栈溢出 2022-01-01
- 如何定义双括号/双迭代器运算符,类似于向量的向量? 2022-01-01
- C++,'if' 表达式中的变量声明 2021-01-01
- 运算符重载的基本规则和习语是什么? 2022-10-31
- C++ 程序在执行 std::string 分配时总是崩溃 2022-01-01