Thread: External error

  1. #1
    Registered User
    Join Date
    Mar 2002
    Posts
    4

    External error2!!!! HELP

    Hi, I am new here. I am a 16 year old high school student. I typed this code for a windows skeleton and i have these 2 errors. IBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
    Debug/MyWin.exe : fatal error LNK1120: 1 unresolved externals
    Error executing link.exe.

    these errors come up after i execute my code. not after i compile it. these errors have come up on other codes too. this is my code:
    #include <windows.h>

    LRESULT CALLBACK WindowFunc(HWND, UINT, WPARAM, LPARAM);
    char szWinName[] = "MyWin";
    int WINAPI WinMain(HINSTANCE hThisInst, HINSTANCE hPrevInst,
    LPSTR lpszArgs, int nWinMode)
    {
    HWND hwnd;
    MSG msg;
    WNDCLASSEX wcl;

    wcl.cbSize = sizeof(WNDCLASSEX);

    wcl.hInstance = hThisInst;
    wcl.lpszClassName = szWinName;
    wcl.lpfnWndProc = WindowFunc;
    wcl.style = 0;

    wcl.hIcon = LoadIcon(NULL, IDI_APPLICATION);
    wcl.hIconSm = NULL;
    wcl.hCursor = LoadCursor(NULL, IDC_ARROW);

    wcl.lpszMenuName = NULL;
    wcl.cbClsExtra = 0;
    wcl.cbWndExtra = 0;

    wcl.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);

    if(!RegisterClassEx(&wcl)) return 0;

    hwnd = CreateWindow(
    szWinName,
    "Windows 2000 Skeleton",
    WS_OVERLAPPEDWINDOW,
    CW_USEDEFAULT,
    CW_USEDEFAULT,
    CW_USEDEFAULT,
    CW_USEDEFAULT,
    NULL,
    NULL,
    hThisInst,
    NULL
    );

    ShowWindow(hwnd, nWinMode);
    UpdateWindow(hwnd);

    while(GetMessage(&msg, NULL, 0, 0))
    {
    TranslateMessage(&msg);
    DispatchMessage(&msg);
    }
    return msg.wParam;
    }


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

    please help me out.

    Thanks,
    Jeff
    Last edited by redsoxj; 03-29-2002 at 09:16 AM.

  2. #2
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,817
    What compiler are you using? It looks like you may have told your compiler you are building a console application in which case, the compiler will expect you to have coded a main function. The WinMain function is used for a Win32 application, the type of program you indicated you wish to create.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  3. #3
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >error LNK2001: unresolved external symbol _main
    This looks like an MSVC++ error. Most likely you are trying to compile a Win32 application in a console project, create a new Win32 application and then paste your code into that and recompile, it should remove that particular error.

    -Prelude
    My best code is written with the delete key.

  4. #4
    Unregistered
    Guest
    I tried to create a win32 application and it said i couldn't exacute it. why?

  5. #5
    Registered User
    Join Date
    Mar 2002
    Posts
    4

    external help2!!!

    i tried to create a win32 application and it wouldn't let me exacute it. why
    Last edited by redsoxj; 03-29-2002 at 09:01 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Testing some code, lots of errors...
    By Sparrowhawk in forum C Programming
    Replies: 48
    Last Post: 12-15-2008, 04:09 AM
  2. more then 100errors in header
    By hallo007 in forum Windows Programming
    Replies: 20
    Last Post: 05-13-2007, 08:26 AM
  3. C++ compilation issues
    By Rupan in forum C++ Programming
    Replies: 1
    Last Post: 08-22-2005, 05:45 AM
  4. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM
  5. ras.h errors
    By Trent_Easton in forum Windows Programming
    Replies: 8
    Last Post: 07-15-2005, 10:52 PM