The Etrain's Gaming and HCI Blog

Installing cURL using Visual Studio 2010 – Beginner’s Guide

by on Jun.17, 2012, under Guides, Programming

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”
  5. Next, create a new line for Library Directories and navigate for cURL>lib>Debug and then click “OK”
  6. Lastly, under Configuration Properties>Linker>Input, edit the Additional Dependencies and create a new line
  7. 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 and add 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.dll, libeay32.dll, openldap.dll, and ssleay32.dll from the cURL directory and into your project folder.
  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.

 


2 Comments for this entry

Leave a Reply

You must be logged in to post a comment.