title: Getting cURL to work with Visual Studios 2017
body: <p>*Edit: I got CURL working in VS 2017 on a 64 bit machine following these steps (see below for original problem):</p>
  
  <p>First install vcpkg:</p>
  
  <ol>
  <li>Clone <a href="https://github.com/Microsoft/vcpkg" rel="noreferrer">vcpkg</a> using gitbash into <code>C:\Program Files</code></li>
  <li>In a command prompt navigate to <code>C:\Program Files\vcpkg</code></li>
  <li>Run in the command prompt: <code>.\bootstrap-vcpkg.bat</code></li>
  <li>Run in the command prompt: <code>vcpkg integrate install</code></li>
  </ol>
  
  <p>Then use vcpkg and Visual Studios 2017 command prompt to install cURL:</p>
  
  <ol start="5">
  <li>Open a <code>VS 2017 Command prompt</code> and navigate to the vcpkg folder (where the <code>vcpkg.exe</code> is)</li>
  <li><p>Run: <code>vcpkg install curl[*]:x64-windows</code> (note this can take around a half hour to download and run, don't worry if it looks like it is "stuck" at parts).</p>
  
  <p>*Edit: previously my instructions said to run <code>vcpkg install curl:x64-windows</code> but I added on the <code>[*]</code> at the behest of @i7clock to enable sftp and scp protocols.</p></li>
  <li><p>After this step, you should check to make sure that curl installed correctly. To do this you should create a new project in VS 2017 and try and include <code>#include curl/curl.h</code> without adding any additional include directories. If you cannot do this then something went wrong with your install of curl. You should remove curl (and perhaps even the vcpkg folder and do a clean install) until you can include <code>curl/curl.h</code>.</p>
  
  <p><strong>*Important Note</strong>: this will only work if you are using x64 debugger/compiling in x64! If you cannot include the curl directory check to make sure your debug is set to the correct version of Windows.</p></li>
  </ol>
  
  <p>You may need to disable SSL peer verification as well:</p>
  
  <ol start="8">
  <li>Place the code <code>curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, FALSE);</code> before the request (see below). Note this is only necessary because I could not figure how to get certificates to work with curl. I have an as-of-yet unanswered stackoverflow post regarding this problem <a href="https://stackoverflow.com/questions/47963081/getting-curl-certificates-to-work-with-c-and-vcpkg-install">here</a>.</li>
  </ol>
  
  <p>Here are some other steps you may need to try to get things running, but I ended up finding them not necessary:</p>
  
  <ol start="9">
  <li>Navigate to vcpkg\packages\curl_x64-windows\lib to find the libcurl.lib file.</li>
  <li>Include the path to libcurl.lib in Additional Library Directories under Properties -> Linker</li>
  <li>Included libcurl.lib in Additional Dependencies under Linker -> Input -> Additional Dependencies</li>
  <li>Place <code>CURL_STATICLIB</code> in Properties -> C/C++ -> Preprocessor -> Preprocessor Definitions</li>
  </ol>
  
  <p>Here is my now working code: </p>
  
  <pre><code>#include "curl/curl.h"
  
  
  void testCurl() {
      CURL *curl;
      CURLcode res; 
  
      curl_global_init(CURL_GLOBAL_ALL); 
  
      curl = curl_easy_init();
      if (curl) {
        curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, FALSE);
        curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
  
      #ifdef SKIP_PEER_VERIFICATION
          curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
      #endif
  
      #ifdef SKIP_HOSTNAME_VERIFICATION
          curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
      #endif
  
      res = curl_easy_perform(curl);
  
     if (res != CURLE_OK)
         fprintf(stderr, "curl_easy_perform() failed: %s\n",
         curl_easy_strerror(res));
  
         curl_easy_cleanup(curl);
   }
   curl_global_cleanup();
  }
  
  int main(){
      testCurl();
      return 0;
  }
  </code></pre>
  
  <p>*Edit: Here is the rest of the explanation of my old problem before it was fixed:</p>
  
  <p>I am trying to use cURL to make an API call so I can start getting real time stock data, but I am running into difficulties getting it to function in VS 2017. I have attempted an <a href="https://github.com/Microsoft/vcpkg" rel="noreferrer">install using vcpckg</a> using the following steps:</p>
  
  <p>According to vcpkg documentation I should be able to now simply #include , but it can't find the folder. If I try including the "include" directory from vcpkg\packages\curl_x86\include and #include  I can build my project. I can also access some of the classes, but if I try and set the curl_global_init(CURL_GLOBAL_DEFAULT) as in this example I get linker errors.</p>
  
  <p><a href="https://i.stack.imgur.com/vZhYZ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/vZhYZ.png" alt="Linker error"></a> 
  <a href="https://i.stack.imgur.com/2IZIe.png" rel="noreferrer"><img src="https://i.stack.imgur.com/2IZIe.png" alt="curl_global_init error"></a> </p>