Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 135113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T06:44:06+00:00 2026-05-11T06:44:06+00:00

Trying to compile a sample http class with the SDK, and getting some strange

  • 0

Trying to compile a sample http class with the SDK, and getting some strange link errors… I am sure its something to do with a missing option, or directory…

I am no expert in c++ as you can see, but looking for any assistance.

I included my sample class. I also did install the Windows SDK. If you need any other information about my setups or anything, please ask. I’d prefer someone point me to a working WinHttp SDK sample project.

//START OF utils.cpp #pragma once #include 'stdafx.h'  class http { public:     http();     ~http();      std::string getText();  }; //END OF utils.cpp 

//START OF utils.cpp #include 'stdafx.h' #include 'utils.h'  http::http() { }  http::~http() { }  std::string http::getText() {     DWORD dwSize = 0;     DWORD dwDownloaded = 0;     LPSTR pszOutBuffer;     BOOL  bResults = FALSE;     HINTERNET  hSession = NULL,          hConnect = NULL,         hRequest = NULL;      // Use WinHttpOpen to obtain a session handle.     hSession = WinHttpOpen( L'WinHTTP Example/1.0',           WINHTTP_ACCESS_TYPE_DEFAULT_PROXY,         WINHTTP_NO_PROXY_NAME,          WINHTTP_NO_PROXY_BYPASS, 0 );      // Specify an HTTP server.     if( hSession )         hConnect = WinHttpConnect( hSession, L'www.microsoft.com',         INTERNET_DEFAULT_HTTPS_PORT, 0 );      // Create an HTTP request handle.     if( hConnect )         hRequest = WinHttpOpenRequest( hConnect, L'GET', NULL,         NULL, WINHTTP_NO_REFERER,          WINHTTP_DEFAULT_ACCEPT_TYPES,          WINHTTP_FLAG_SECURE );      // Send a request.     if( hRequest )         bResults = WinHttpSendRequest( hRequest,         WINHTTP_NO_ADDITIONAL_HEADERS, 0,         WINHTTP_NO_REQUEST_DATA, 0,          0, 0 );       // End the request.     if( bResults )         bResults = WinHttpReceiveResponse( hRequest, NULL );      // Keep checking for data until there is nothing left.     if( bResults )     {         do          {             // Check for available data.             dwSize = 0;             if( !WinHttpQueryDataAvailable( hRequest, &dwSize ) )                 printf( 'Error %u in WinHttpQueryDataAvailable.\n',                 GetLastError( ) );              // Allocate space for the buffer.             pszOutBuffer = new char[dwSize+1];             if( !pszOutBuffer )             {                 printf( 'Out of memory\n' );                 dwSize=0;             }             else             {                 // Read the data.                 ZeroMemory( pszOutBuffer, dwSize+1 );                  if( !WinHttpReadData( hRequest, (LPVOID)pszOutBuffer,                      dwSize, &dwDownloaded ) )                     printf( 'Error %u in WinHttpReadData.\n', GetLastError( ) );                 else                     printf( '%s', pszOutBuffer );                  // Free the memory allocated to the buffer.                 delete [] pszOutBuffer;             }         } while( dwSize > 0 );     }       // Report any errors.     if( !bResults )         printf( 'Error %d has occurred.\n', GetLastError( ) );      // Close any open handles.     if( hRequest ) WinHttpCloseHandle( hRequest );     if( hConnect ) WinHttpCloseHandle( hConnect );     if( hSession ) WinHttpCloseHandle( hSession );      return ''; } //END OF utils.cpp 

1>------ Build started: Project: winagent, Configuration: Debug Win32 ------ 1>Compiling... 1>utils.cpp 1>Linking... 1>   Creating library C:\winagent\Debug\winagent.lib and object C:\winagent\Debug\winagent.exp 1>utils.obj : error LNK2019: unresolved external symbol __imp__WinHttpCloseHandle@4 referenced in function 'public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall http::getText(void)' (?getText@http@@QAE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ) 1>utils.obj : error LNK2019: unresolved external symbol __imp__WinHttpReadData@16 referenced in function 'public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall http::getText(void)' (?getText@http@@QAE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ) 1>utils.obj : error LNK2019: unresolved external symbol __imp__WinHttpQueryDataAvailable@8 referenced in function 'public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall http::getText(void)' (?getText@http@@QAE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ) 1>utils.obj : error LNK2019: unresolved external symbol __imp__WinHttpReceiveResponse@8 referenced in function 'public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall http::getText(void)' (?getText@http@@QAE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ) 1>utils.obj : error LNK2019: unresolved external symbol __imp__WinHttpSendRequest@28 referenced in function 'public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall http::getText(void)' (?getText@http@@QAE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ) 1>utils.obj : error LNK2019: unresolved external symbol __imp__WinHttpOpenRequest@28 referenced in function 'public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall http::getText(void)' (?getText@http@@QAE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ) 1>utils.obj : error LNK2019: unresolved external symbol __imp__WinHttpConnect@16 referenced in function 'public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall http::getText(void)' (?getText@http@@QAE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ) 1>utils.obj : error LNK2019: unresolved external symbol __imp__WinHttpOpen@20 referenced in function 'public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall http::getText(void)' (?getText@http@@QAE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ) 1>C:\winagent\Debug\winagent.exe : fatal error LNK1120: 8 unresolved externals 1>Build log was saved at 'file://c:\winagent\Debug\BuildLog.htm' 1>winagent - 9 error(s), 0 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T06:44:07+00:00Added an answer on May 11, 2026 at 6:44 am

    If you check the MSDN reference for the WinHttp* functions you will see that you need to link with the library Winhttp.lib.

    Open the project settings, select the linker options then ‘input’ and add WinHttp.lib to the ‘Additional Dependencies’ list.

    Or you could put

    #pragma comment(lib, 'winhttp.lib') 

    (as previously mentioned) in your source code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 96k
  • Answers 96k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Try to learn a little bit of theory too. Such… May 11, 2026 at 7:11 pm
  • Editorial Team
    Editorial Team added an answer var stringValue = String(foo); or even shorter var stringValue =… May 11, 2026 at 7:11 pm
  • Editorial Team
    Editorial Team added an answer After wrestling with this for a really long time, it… May 11, 2026 at 7:11 pm

Related Questions

I'm trying to build some code for dynamically sorting a Linq IQueryable<>. The obvious
I've had significant success with NSURL, NSURL[Mutable]Request, NSURLConnection with my iPhone applications. When trying
I'm new to WCF and trying to get my first service running. I'm close
I'm trying to write a simple WCF Server + gSOAP client proof-of-concept application using

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.