1

I'm a beginner to programming. I keep getting this error as I run my program. I have already checked online and many people suggest to add /* #pragma comment(lib, "wininet.lib") */ after all the includes, or to change property setting.
I changed both so far, but the message is still there.
I'm using 2010 Microsoft Visual Studio and the entire error message is below:

1>MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol WinMain@16 referenced >in function __tmainCRTStartup
1>C:\Users\Username\Desktop\Winlnet test\Debug\Winlnet test.exe : fatal error LNK1120: 1 >unresolved externals
1>
1>Build FAILED.
1>

any help is greatly appreciated!! below is the program.

#include <string>
#include <iostream>
#include <fstream>
#include <windows.h>
#include <wininet.h>
#include <winsock.h>
#include <stdio.h>
#include <stdarg.h>

#pragma comment(lib, "wininet.lib")

using namespace std;

int main()      
{
HINTERNET hOpen, hURL;
LPCWSTR NameProgram = L"Webreader";             //      LPCWSTR == Long Pointer to Const Wide String 
LPCWSTR Website;                    
char file[101];
unsigned long read;

//Always need to establish the internet connection with this funcion.  
  if ( !(hOpen = InternetOpen(NameProgram, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0 )))
    {
    cerr << "Error in opening internet" << endl;
    return 0;
    }                       
Website = L"http://www.google.com";
hURL = InternetOpenUrl( hOpen, Website, NULL, 0, 0, 0 );            //Need to open the URL


InternetReadFile(hURL, file, 100, &read);
while (read == 100)
    {
    InternetReadFile(hURL, file, 100, &read);
    file[read] = '\0';
    cout << file;
    }

cout << endl;
InternetCloseHandle(hURL);
return 0;
}
Honeycrisp
  • 53
  • 2
  • 12
  • You have no `WinMain()` function. Nothing to do with `wininet`. – Aneri May 27 '13 at 19:52
  • Could you please explain more? Thank you so much!! – Honeycrisp May 27 '13 at 19:56
  • 2
    You appear to have selected Windows Application rather than Console Application. In the former your entry point is called `WinMain()` and no console window is generated for you. So you most probably need to make your project a Console Application. – Aneri May 27 '13 at 19:57
  • @Aneri Thank you so much!! that is a huge help! – Honeycrisp May 29 '13 at 18:21
  • @Aneri sorry for interrupting! I'm a very beginner, could you please help me explain the difference a little bit? windows applications and console application. Thank you very much!! – Honeycrisp Jun 04 '13 at 18:14
  • http://en.wikipedia.org/wiki/Console_application http://en.wikipedia.org/wiki/Graphical_user_interface#Comparison_to_other_interfaces Look at these. Note that every process has stdin, stdout and stderr. These files can be either bound to a console window handles, or be unbound. The former is the console application case (a console window is created for you if there is none). The latter draws its own GUI, thus rarely use std handles. – Aneri Jun 05 '13 at 22:55

0 Answers0