title: Linker error using wininet in c++
body: <p>I'm going to upload data using wininet in c++.<br />
  Here is a code.</p>
  <pre><code>        #include &quot;stdafx.h&quot;
      #include &quot;iostream&quot;
      #include &quot;windows.h&quot;
      #include &quot;wininet.h&quot;
      #include &quot;tchar.h&quot;
      #include &quot;iostream&quot;
      #include &quot;string&quot;
      #include &quot;sstream&quot;
  
      #pragma comment(lib, &quot;ws2_32.lib&quot;)
  
      int main(){
  
              TCHAR hdrs[] = _T(&quot;Content-Type: application/x-www-form-urlencoded&quot;);
      TCHAR frmdata[] = _T(&quot;name=John+Doe&amp;userid=hithere&amp;other=P%26Q&quot;);
      LPCTSTR accept[] = {_T(&quot;*/*&quot;), NULL};
  
      HINTERNET hSession = InternetOpen(_T(&quot;MyAgent&quot;), INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
      HINTERNET hConnect = InternetConnect(hSession, _T(&quot;http://localhost&quot;), INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 1);
      HINTERNET hRequest = HttpOpenRequest(hConnect, _T(&quot;POST&quot;), _T(&quot;/upload.php&quot;), NULL, NULL, accept, 0, 1);
      HttpSendRequest(hRequest, hdrs, _tcslen(hdrs), frmdata, _tcslen(frmdata));
  
  
         return 0;
  
          }
  </code></pre>
  <p>I am using visual studio 2012 for compiling it.<br />
  I also compile it in dev c++ but the error is same.</p>
  <blockquote>
  <p>1&gt;asdfg.obj : error LNK2019: unresolved external symbol __imp__InternetOpenW@20 referenced in function _main</p>
  <p>1&gt;asdfg.obj : error LNK2019: unresolved external symbol __imp__InternetConnectW@32 referenced in function _main<br />
  1&gt;asdfg.obj : error LNK2019: unresolved external symbol __imp__HttpOpenRequestW@32 referenced in function _main<br />
  1&gt;asdfg.obj : error LNK2019: unresolved external symbol __imp__HttpSendRequestW@20 referenced in function _main</p>
  </blockquote>
  <p><strong>UPDATE</strong><br />
  I'm using <code>#pragma comment(lib, &quot;Wininet.lib&quot;)</code> also and getting no error.<br />
  all the program compile successfully but the data is not upload.<br />
  here is php file.</p>
  <pre><code>&lt;?php
  
      $name = $_POST['name'];
      $userid = $_POST['userid'];
      $other = $_POST['other'];
  
      $myfile = fopen(&quot;newfile.txt&quot;, &quot;w&quot;) or die(&quot;Unable to open file!&quot;);
      $txt1 = $name.&quot;\n&quot;;
      fwrite($myfile, $txt1);
      $txt2 = $userid.&quot;\n&quot;;
      fwrite($myfile, $txt2);
      $txt3 = $other.&quot;\n&quot;;
      fwrite($myfile, $txt3);
      fclose($myfile);
  
     ?&gt;
  </code></pre>