Advertisement

07.11.2004 at 06:51AM PDT, ID: 21054716
[x]
Attachment Details

LNK2001: unresolved external symbol _main

Asked by xLeon in Microsoft Visual C++.Net

Tags: external, unresolved, symbol, _main

Hello,
I'm learning WinAPI and I can't run the code from tutorial. There is this link error:

Linking...
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/main.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

main.exe - 2 error(s), 0 warning(s)

the code is as follows

#include <windows.h>

#define _MainClassName TEXT("WinAPIMainClass")
#define _AppName TEXT("We learn WinAPI")

HINSTANCE g_hInstance;
HWND g_hwndMain;

LRESULT CALLBACK WindowProcMain(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
      switch ( message )
      {
            case WM_DESTROY:
                  PostQuitMessage(0);
                  break;
      }
      return DefWindowProc(hwnd, message, wParam, lParam);
}


BOOL InitApp()
{
      WNDCLASSEX wc;
      wc.cbSize = sizeof(WNDCLASSEX);
      wc.cbClsExtra = 0;
      wc.cbWndExtra = 0;
      wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
      wc.hCursor = LoadCursor(NULL, IDC_ARROW);
      wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
      wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
      wc.hInstance = g_hInstance;
      wc.lpfnWndProc = WindowProcMain;
      wc.lpszClassName = _MainClassName;
      wc.lpszMenuName = NULL;
      wc.style = CS_HREDRAW | CS_VREDRAW;
      if ( !RegisterClassEx(&wc) )
            return FALSE;

      g_hwndMain = CreateWindowEx(0, _MainClassName,
            _AppName,
            WS_OVERLAPPEDWINDOW | WS_VISIBLE,
            100, 100, 450, 350,
            NULL, NULL, g_hInstance, NULL);
      if ( g_hwndMain == NULL )
            return FALSE;
      return TRUE;
}

MSG msg;

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nShow)
{
      if ( !InitApp() )
            return FALSE;
      g_hInstance = hInstance;
      while ( GetMessage(&msg, NULL, 0, 0) )
      {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
      }
      return msg.wParam;
}

thanks for answer
Start Free Trial
[+][-]07.11.2004 at 12:50PM PDT, ID: 11524655

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.11.2004 at 02:38PM PDT, ID: 11525084

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.11.2004 at 04:44PM PDT, ID: 11525596

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Microsoft Visual C++.Net
Tags: external, unresolved, symbol, _main
Sign Up Now!
Solution Provided By: vascov
Participating Experts: 4
Solution Grade: A
 
 
[+][-]07.11.2004 at 04:50PM PDT, ID: 11525620

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.11.2004 at 06:14PM PDT, ID: 11525894

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.12.2004 at 11:54AM PDT, ID: 11532245

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.16.2004 at 12:28PM PDT, ID: 11571548

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32