cURL与Visual Studio 2013 [英] cURL with Visual Studio 2013

查看:777
本文介绍了cURL与Visual Studio 2013的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我一起来的cURL作为一个非常好的库,并在OSX工作非常好。
但是在windows上,我有一个很大的麻烦,准备好这个库。我现在搜索约2天,并尝试了十多(详细)不同的方式来使这个准备好。没有任何成功。



这里有一些基本的尝试方法:


  1. 下载:此处的问题已从正确的下载开始。官方下载页面很混乱,所以我认为这个cURL下载向导>libcurl开发,它给了我一个版本,我应该能够包括到任何项目。但是究竟如何包含呢?在任何指示,它导致我到目录我甚至没有。几乎总是提到这个curllib.lib。我在那个下载页面下载了大约6个不同的版本,其中没有这个文件。 (例如,请参阅 this 说明)

  2. Git + CMake :作为上述链接的解决方案,建议使用git clone。我做了所有的指示,并得到的项目生成与只是警告。但在这里它也说:

    构建安装目标后,你会在C:\curl.vc12中找到bin / include / lib文件夹
    好吧,没有真正得到他的观点构建安装目标,我只是构建整个项目地图,因为它来。编译精细(115个成功,0个失败,2个跳过)。但现在C:\curl.vc12不存在。在编译之前我需要预先设置什么?

  3. NuGet :该想法来自第(1)点中的链接,是NuGet的另一个解决方案。

    使用成功添加curl 7.30.0.2以测试。它也似乎不错,但编译 simple.c 导致一系列未解析的外部符号链接器错误。但提供了一个解决方案:

    确保include目录和lib目录在项目属性中的Visual C ++目录下指定。

    所以在项目>属性> VC ++属性> 包括目录
    项目>属性> VC ++属性> Library Directories
    以及 Project> C / C ++>一般> Additional Include Directories Project>接头>一般> 附加库目录我拼命添加了我的项目文件夹中的\packages \路径。

    如说明中所述,我添加了 libcurl.lib; libeay32.lib; ssleay32.lib; Ws2_32.lib; libssh2.lib; zlib.lib; wldap32.lib; 项目>接头>输入> 其他依赖关系

    所做的一切,未解决的外部符号错误消失了!因此,我只得到一个错误,说无法打开文件'libcurl.lib'。我可以在这里做什么?

我很新鲜。但我现在真的很努力,让这终于工作。那么我该怎么办呢?

我使用Visual Studio 2013社区版。目前最新版本的cURL是 7.42.1
非常欢迎任何帮助!

解决方案

自己有问题,终于得到了工作。
我从官方网站下载了 curl-7.42.1.zip
在归档文件中,你会找到源代码和winbuild / BUILD.WINDOWS.txt,它基本上包含我遵循的指令。我假设它已解压到C:\curl-7.42.1。



打开 Visual Studio命令提示符位于



< >

C:\Program Files(x86)\Microsoft Visual Studio 12.0 \Common7\Tools\Shortcuts


这会自动设置使用Visual Studio工具(如编译器)所需的环境变量。然后移动到winbuild目录并调用


nmake / f Makefile.vc mode = dll




这将创建目录


C:\curl-7.42.1\builds\libcurl-vc-x86-release-dll-ipv6-sspi-winssl


包含libcurl.dll,libcurl.lib和必要的头文件。让我们将它重命名为 C:\curl-7.42.1\builds\release :'D


  1. 然后打开您的项目。

  2. 打开项目的属性。

  3. 确保选择 >作为配置(左上角)!

  4. 导航到 VC ++目录>包含目录并添加 C:\curl-7.42.1\builds\release\include

  5. C:\curl-7.42.1 \builds\release\lib 添加到 VC ++目录>库目录

  6. 转到链接器>输入>附加依赖关系并添加 libcurl.lib

  7. \\ curl-7.42.1 \builds\release\bin\libcurl.dll 到您的专案资料夹。

这应该做的伎俩! :D如果你想在调试模式下使用cURL,你可以做同样的事情,使用 nmake / f Makefile.vc mode = dll debug = yes 重新编译,项目的属性,添加新创建的目录路径(将libcurl.lib更改为libcurl_debug.lib),您应该这样做。


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:

  1. 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)
  2. 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?
  3. NuGet: The idea comes from the link in point (1) again, a different solution with NuGet.
    With Successfully added 'curl 7.30.0.2' to test. it also seemed nice, but compiling simple.c leads to a bunch of unresolved 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 in Project > Properties > VC++ Properties > "Include Directories" and
    Project > Properties > VC++ Properties > "Library Directories"
    as well as in Project > C/C++ > General > "Additional Include Directories" and in Project > Linker > General > "Additional Library Directories" I desperately added the \packages\ path from my project folder.
    As mentioned in the instructions, I added libcurl.lib;libeay32.lib;ssleay32.lib;Ws2_32.lib;libssh2.lib;zlib.lib;wldap32.lib; to Project > Linker > Input > "Additional Dependencies".
    All that done, the unresolved external symbol errors are gone! Therefore I get just one error saying cannot open file 'libcurl.lib'. What can I do here?

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!

解决方案

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.

Open the Visual Studio command prompt located at

C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\Shortcuts

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

as described in the text file I mentioned above.

That will create the directory

C:\curl-7.42.1\builds\libcurl-vc-x86-release-dll-ipv6-sspi-winssl

containing libcurl.dll, libcurl.lib and the necessary header files. Let's rename it to C:\curl-7.42.1\builds\release :'D

  1. Then open your project.
  2. Open your project's properties.
  3. Make sure you choose Release as configuration (top left corner)!
  4. Navigate to VC++ Directories > Include directories and add C:\curl-7.42.1\builds\release\include
  5. Add C:\curl-7.42.1\builds\release\lib to VC++ Directories > Library directories.
  6. Go to Linker > Input > Additional Dependencies and add libcurl.lib.
  7. Finally copy C:\curl-7.42.1\builds\release\bin\libcurl.dll to your project folder.

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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆