c++ vs2010下安装curl

本文详细介绍了如何在Windows 7环境下使用Visual Studio 2010安装cURL库,包括准备文件、链接库等步骤,并提供了解决运行时缺少DLL文件的简单方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

转自:http://theetrain.ca/tech/installing-curl-using-visual-studio-2010-beginners-guide/

Installing cURL using Visual Studio 2010 – Beginner’s Guide

cURL is a library used to allow C++ applications to communicate with online databases and PHP sites.

For the record, I am a beginner when it comes to cURL. I recently started using this library, and I must say that installing it was too challenging. I Googled for guides up and down the Internet until I came across the only useful one here.

That being said, I wish the cURL documentation was better. It probably makes a lot of sense to experienced users, but to beginners installing it for the first time, it appears like walls of gibberish. Just for you, I will show you the secret ways of installing cURL on Microsoft Visual Studio 2010 on Windows 7.

A: Prepare your files

  1. Download cURL and save it somewhere accessible. Advanced programmers may choose to throw it on their C:\. It’s personal preference.
  2. Once extracted into your favourite directory, open Visual Studio and create an empty project.
  3. In your cURL directory, go to docs\examples and copy and paste simple.c into your new project.

So far your project folder should look like this:

I called mine “dummy.”

B: Link your libraries

  1. You may try pressing F7, but it won’t work. You need to set up your linker and what-not.
  2. On the toolbar, go to Project>Properties
  3. Go to Configuration Properties>VC++ Directories>Include Directories and go to <Edit> (click on the drop-down arrow to the right)
  4. Create a new line and browse for your cURL directory. Browse for cURL>include>curl and then click “OK”【注意:如果程序中有类似#include <curl/curl.h>,则此时只要添加到 cURL>include 就可以,不必添加curl这个子文件夹了。】




  1. Next, create a new line for Library Directories and navigate for cURL>lib>Debug and then click “OK”

  1. Lastly, under Configuration Properties>Linker>Input, edit the Additional Dependencies and create a new line


  1. Browse for cURL>lib>Debug>curllib.lib and paste its source link into your Additional Dependencies dialogue box

Like this

 

Try the sample code

  1. If you haven’t done so already, go to your solution explorer and under Source Files, Right-Click andadd existing files, browse for “simple.c
  2. Open the file and change line 12 to read #include <curl.h>
  3. Press F7 and watch the magic.
  4. During run-time, however, there will be errors due to missing DLL files. This can be easily fixed by copying and pasting curllib.dlllibeay32.dllopenldap.dll, and ssleay32.dll from the cURL directory and into your project folder【注意添加的路径问题,要放在项目的下图所示的路径中,否则会出现 找不到dll的错误。】}
  5. Believe it or not, you also need libsasl.dll, so here you go! I know, why wouldn’t it be included in the cURL package if it was required for run time?
  6. Press F5 and everything should work.


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值