Archived

This topic is now archived and is closed to further replies.

Sarlok

"unresolved external symbol _main ; Error running link.exe"

Recommended Posts

So very frustrating. I''ve basically put together a skeleton window, It gives me that error. I decided to try editing another program I made, and taking out the things I added to the message loop and window class (just a pair of icons, etc), also removing un-need files and headers from the workspace (resource.h, menu.h, ICO_1.ico, etc). In all respects, reducing it to a mirror image of the new one I made from scratch. I recompiled, and away it went. Hmm. That''s fine. I copy the source code for my now working duplicate, and copy it into a new file. I do the same with stdafx.h (not that there''s much left in it anyway), hit compile/run and bam. I get that linker error message again. Am I not defining something that somehow stops the linker? I''ve gone through my source code numerous times, and there *is no difference* from the version that works, to the version that doesn''t, except for the fact that the version that works, was cut down from a goofy little window I made that detects mouse clicks, had a menu, and some icons. For those interested, the source code: Note: I Don''t know the UBB tag that lets me keep code nested and ''small''. Allthough, I wouldn''t mind knowing. -_-_-_-_-_-_-_-_-_-_ #include "stdafx.h" const char g_szClassName[] = "myWindowClass"; LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_CLOSE: DestroyWindow(hwnd); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hwnd, msg, wParam, lParam); } return 0; } int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { WNDCLASSEX wc; HWND hwnd; MSG Msg; wc.cbSize = sizeof(WNDCLASSEX); wc.style = 0; wc.lpfnWndProc = WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = 0; wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)(COLOR_WINDOW); wc.lpszMenuName = 0; wc.lpszClassName = g_szClassName; wc.hIconSm = 0; if(!RegisterClassEx(&wc)) { MessageBox(NULL, "Error at: RegisterClassEx(&wc)", "Fail", MB_ICONEXCLAMATION | MB_OK); return 0; } hwnd = CreateWindowEx(WS_EX_CLIENTEDGE, g_szClassName, "A Window", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 320, 240, NULL, NULL, hInstance, NULL); if(hwnd == NULL) { MessageBox(NULL, "Error at: hwnd == NULL", "Fail", MB_ICONEXCLAMATION | MB_OK); return 0; } ShowWindow(hwnd, nCmdShow); UpdateWindow(hwnd); while(GetMessage(&Msg, NULL, 0, 0)) { TranslateMessage(&Msg); DispatchMessage(&Msg); } return Msg.wParam; } // End -_-_-_-_-_-_-_-_-_-_ Contents of stdafx.h #define WIN32_LEAN_AND_MEAN // Tried removing this. #include <windows.h> -_-_-_-_-_-_-_-_-_-_ That''s it. Thanks.

Share this post


Link to post
Share on other sites
Go to Project Settings->Link and check your subsystem (in the Project Options edit box).

If it''s /subsystem:console, you can either change it to /subsystem:windows or delete the option and let it be determined automatically .

Share this post


Link to post
Share on other sites