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
- Download cURL and save it somewhere accessible. Advanced programmers may choose to throw it on their C:\. It’s personal preference.
- Once extracted into your favourite directory, open Visual Studio and create an empty project.
- 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
- You may try pressing F7, but it won’t work. You need to set up your linker and what-not.
- On the toolbar, go to Project>Properties
- Go to Configuration Properties>VC++ Directories>Include Directories and go to <Edit> (click on the drop-down arrow to the right)
- Create a new line and browse for your cURL directory. Browse for cURL>include>curl and then click “OK”
- Next, create a new line for Library Directories and navigate for cURL>lib>Debug and then click “OK”
- Lastly, under Configuration Properties>Linker>Input, edit the Additional Dependencies and create a new line
- Browse for cURL>lib>Debug>curllib.lib and paste its source link into your Additional Dependencies dialogue box
Try the sample code
- 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“
- Open the file and change line 12 to read #include <curl.h>
- Press F7 and watch the magic.
- 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.
- 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?
- Press F5 and everything should work.