linking error help
Im using MVC++ and trying to make a window for a directx game.
In my code I have not declared any dc header files and am just using headers the compiler came with. I made a win32 application and then made a new c++ file in the workspace my code compiles ok but it is when I try and run it is when I get the errors the code is
#include
#include
const char *CLASSNAME = "Tutorial", *WINNAME = "Tutorial 2 - The Window";
LRESULT CALLBACK WndProc(HWND hWnd, unsigned int iMessage, WPARAM wParam, LPARAM lParam);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int nCmdShow)
{
HWND hWnd;
MSG Message;
WNDCLASS WndClass;
// NOTE: The memset() here is added to deal with this code crashing on
// WinNT (reported by Girish Deodhar, solution due to him as well)
// The extra include statement is for memset() too...
memset(&WndClass, 0, sizeof(WndClass));
WndClass.cbClsExtra = 0;
WndClass.cbWndExtra = 0;
// Typecast added. This line generated compiler errors on some
// compilers previously. Thanks goes to Anton Rapoport for the tip.
WndClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
WndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
WndClass.hIcon = LoadIcon(hInstance, NULL);
WndClass.hInstance = hInstance;
WndClass.lpfnWndProc = WndProc;
WndClass.lpszClassName = CLASSNAME;
WndClass.style = CS_HREDRAW / CS_VREDRAW;
if(!RegisterClass(&WndClass))
return 0;
hWnd = CreateWindow(CLASSNAME, WINNAME, WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, 300, 100,
NULL, NULL, hInstance, NULL);
ShowWindow(hWnd, nCmdShow);
while(GetMessage(&Message, hWnd, 0, 0))
{
TranslateMessage(&Message);
DispatchMessage(&Message);
}
return Message.wParam;
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam)
{
switch(iMessage)
{
case WM_CLOSE:
case WM_DESTROY:
if(MessageBox(hWnd, "Do you really want to quit?", "Message", MB_YESNO) == IDYES)
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, iMessage, wParam, lParam);
}
return 0;
}
and the linking errors are
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/dxx.exe : fatal error LNK1120: 1 unresolved externals
I can''t see what you are including because the message board dont like to print stuff inside of those braces but you need to include
windows.h
windowsx.h
mmsystem.h
i believe you only need the last one if you are going to use multi-media features like sound and such for your application
but it is good to include it anyway
"Now go away or I shall taunt you a second time"
- Monty Python and the Holy Grail
windows.h
windowsx.h
mmsystem.h
i believe you only need the last one if you are going to use multi-media features like sound and such for your application
but it is good to include it anyway
"Now go away or I shall taunt you a second time"
- Monty Python and the Holy Grail
quote: Original post by OoMMMoO
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/dxx.exe : fatal error LNK1120: 1 unresolved externals
The linker can't find the function 'main'. Windows programs don't use it (well, they do, but in the background), so I suspect you've created a console application, or your project settings have gotten screwed up.
Either that, or the compiler has gone mad and is not looking in the right place for things.
Create a new "Win32 application" project, and see if it compiles:
-If it does, that means your project is somehow misconfigured. The easiest solution is to create a new project for yourself (or use the one you just used to test the system), and copy files over to it.
-If it doesn't, I'd say you're looking at reinstalling VC++.
TheTwistedOne
http://www.angrycake.com
Edited by - TheTwistedOne on June 13, 2000 5:24:14 AM
TheTwistedOnehttp://www.angrycake.com
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement