I am trying to make a simple engine with WinAPI and I encounter this problem:

class Window {
	        static HINSTANCE hInst;
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
	LPSTR lpCmdLine, int nCmdShow)
	MSG msg;
	Window::hInst = hInstance;

The errors:

main.obj : error LNK2001: unresolved external symbol "public: static struct HINSTANCE__ * Window::hInst" (?hInst@Window@@2PAUHINSTANCE__@@A)
C:\Users\invisal\Documents\Visual Studio 2008\Projects\Project1\StuMg\Debug\StuMg.exe : fatal error LNK1120: 1 unresolved externals
Build log was saved at "file://c:\Users\invisal\Documents\Visual Studio 2008\Projects\Project1\StuMg\StuMg\Debug\BuildLog.htm"
StuMg - 2 error(s), 0 warning(s)

Recommended Answers

All 2 Replies

Try placing a line like:

HINSTANCE Window::hInst;

and initialize it with a default value if possible like a good little variable outside the class; after the closing semicolon of the class declaration and before declaring main().

commented: thank man :D +5

That works perfectly. Thank very much :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.