1

I would like to have my C++ program read a web source using libcurl, but it can not open the file "curl.h".

image

Remy Lebeau
  • 505,946
  • 29
  • 409
  • 696

2 Answers2

1

Unless you've instructed your compiler to search for headers in a place that the curl library is installed independently, you're probably looking for double quotes, assuming you've included curl source. Otherwise you're going to need to fiddle around with include paths in the project settings.

What is the difference between #include <filename> and #include "filename"?

The difference is in the location where the preprocessor searches for the included file.

For #include "filename" the preprocessor searches in the same directory as the file containing the directive, and then like for #include . This method is normally used to include programmer-defined header files.

For #include < filename > the preprocessor searches in an implementation dependent manner, normally in search directories pre-designated by the compiler/IDE. This method is normally used to include standard library header files.

Community
  • 1
  • 1
Josh
  • 12,382
  • 2
  • 39
  • 46
0
In short, 
Add the path of the libcurl's include folder in C/C++ -? General -> Additional include directories. This way the Visual Studio will get to know the location of curl.h

In Detail:
Using libcurl involves 2 steps:
1. Download and build libcurl on your platform.
2. Plug-it in your C\C++ application

Step 1: 
Download code from https://curl.haxx.se/download.html and unzip the zip file in a folder.  I guess you already have done it. 
cd curl-src\winbuild
nmake /f Makefile.vc mode=<static or dll>  <options>
VC=<6,7,8,9,10,11,12,14>     - VC versions
  WITH_DEVEL=<path>            - Paths for the development files (SSL, zlib, etc.)
                                 Defaults to sibbling directory deps: ../deps
                                 Libraries can be fetched at http://windows.php.net/downloads/php-sdk/deps/
                                 Uncompress them into the deps folder.
  WITH_SSL=<dll or static>     - Enable OpenSSL support, DLL or static
  WITH_MBEDTLS=<dll or static> - Enable mbedTLS support, DLL or static
  WITH_CARES=<dll or static>   - Enable c-ares support, DLL or static
  WITH_ZLIB=<dll or static>    - Enable zlib support, DLL or static
  WITH_SSH2=<dll or static>    - Enable libSSH2 support, DLL or static
  ENABLE_SSPI=<yes or no>      - Enable SSPI support, defaults to yes
  ENABLE_IPV6=<yes or no>      - Enable IPv6, defaults to yes
  ENABLE_IDN=<yes or no>       - Enable use of Windows IDN APIs, defaults to yes
                                 Requires Windows Vista or later, or installation from:
                                 https://www.microsoft.com/downloads/details.aspx?FamilyID=AD6158D7-DDBA-416A-9109-07607425A815
  ENABLE_WINSSL=<yes or no>    - Enable native Windows SSL support, defaults to yes
  GEN_PDB=<yes or no>          - Generate Program Database (debug symbols for release build)
  DEBUG=<yes or no>            - Debug builds
  MACHINE=<x86 or x64>         - Target architecture (default is x86)

For More info, you can read INSTALL file present in the downloaded zip.

Step 2: Once you have the library built, plug-it in you application as:
a) Right Click the VS project in which you want to add the dependency of curl and select properties.
b) Add the path of the libcurl's include folder in C/C++ -> General -> Additional include directories. This way the Visual Studio will get to know the location of curl.h
c) Add the path of libcurl library in linker -> General -> Additional  Library Directories. 
d) Mention libcurl name in Linker -> input -> Additional Dependencies. 

You are good to go ! 
Note: if you are using dll for curl, then this dll should be present in the same directory in which your .exe for the application is present.