title: How to use curl Nuget package in C++ application
body: <p>I am trying to use curl in a C++ application I am developing using Visual Studio 2017. I like the idea of using Nuget because it is a very clean way of implementing a library. I tried to follow the example below from the Microsoft forum, which led me to use the “rmt_curl” package (linked below). This, however, left VS unable to find “curl.h”.</p>
  
  <p><a href="https://social.msdn.microsoft.com/Forums/sqlserver/en-US/a5cf5caa-450e-425b-af5b-84f8e1c198f9/c-visual-studio-2015-how-to-include-nuget-package-in-my-project?forum=vcgeneral" rel="nofollow noreferrer">https://social.msdn.microsoft.com/Forums/sqlserver/en-US/a5cf5caa-450e-425b-af5b-84f8e1c198f9/c-visual-studio-2015-how-to-include-nuget-package-in-my-project?forum=vcgeneral</a></p>
  
  <p><strong>rmt_curl</strong> nuget package:
  <a href="https://www.nuget.org/packages/rmt_curl/" rel="nofollow noreferrer">https://www.nuget.org/packages/rmt_curl/</a></p>
  
  <p>So I switched to use the “curl” package, which fixed the header file, but resulted in “unresolved external symbol” for each of the curl functions.</p>
  
  <p><strong>curl</strong> nuget package:
  <a href="https://www.nuget.org/packages/curl/" rel="nofollow noreferrer">https://www.nuget.org/packages/curl/</a></p>
  
  <p>Inspired by other comments and answers I added “libcurl.lib” to the project “Properties->Linker->Input->Additional Dependencies” list. This results in “cannot open file ‘libcurl.lib’”.</p>
  
  <p>After trying about half of the “libcurl.lib files in the “packages\curl.7.30.0.2” folder, I finally found one that compiled. I added “$(SolutionDir)\packages\curl.7.30.0.2\build\native\lib\v110\Win32\$(Configuration)\dynamic” to the project “Properties->Linker->General->Additional Library Directories” field.</p>
  
  <p>Now the problem is that when running it, “LIBCURL.dll is not found”. This made realize that earlier I liked against the dynamic version of the .lib file. This is not what I want. I want to statically link the library and not bother with a DLL.</p>
  
  <p>Here is the sample code I am trying to run before I try this in my real application:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>#include "stdafx.h"
  #include &lt;iostream&gt;
  #include &lt;stdio.h&gt;
  #include &lt;curl/curl.h&gt;
  
  
  int main()
  {
      CURL *curl;
      CURLcode res;
  
      curl = curl_easy_init();
      if (curl) {
          curl_easy_setopt(curl, CURLOPT_URL, "http://google.com");
          res = curl_easy_perform(curl);
  
          /* always cleanup */
          curl_easy_cleanup(curl);
      }
      return 0;
  }
  </code></pre>
  
  <p>I looked in detail at each of these related questions and if the answer that I need is in there, I do not see it:</p>
  
  <p><a href="https://stackoverflow.com/questions/44388168/unresolved-external-symbol-using-curl-nuget">unresolved external symbol using curl NuGet</a></p>
  
  <p><a href="https://stackoverflow.com/questions/30288415/curl-with-visual-studio-2013">cURL with Visual Studio 2013</a></p>
  
  <p><a href="https://stackoverflow.com/questions/26926417/curl-nuget-visual-studio-2013-unresolved-external-symbol-imp-curl-easy-init-r">CURL Nuget visual studio 2013 unresolved external symbol __imp__curl_easy_init referenced in function _main()</a></p>
  
  <p><a href="https://stackoverflow.com/questions/44270038/add-curl-library-c">Add curl library C++</a></p>
  
  <p>This is the first time I am using Nuget with a C++ project, so it is very possible that I simply do not understand something simple.</p>