Hi,
I've been trying to do some of the examples on functionx.com, but I'm having difficulty getting one of them to compile. I'm working from this tutorial:
Win32 Programming - Lesson 6: Object-Oriented Win32
I copied out the code for the example program beneath the heading "Win32 Object Programming", which is about halfway down that page. As instructed, I created "MainWnd.h", "WinApp.h", "WinApp.cpp", and "Exercise.cpp".
Initially, I had a few problems with converting between different types of char variable. SO in exercise.cpp, I changed WinMain to look like this:
Similarly, in WinApp.cpp, I changed WApplication::WApplication to look like this:Code:INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nCmdShow) { MSG Msg; LPCTSTR ClsName_T = L"Win32OOP"; LPCTSTR WndName = L"Object-Oriented Win32 Programming"; int copy1 = 0; char *ClsName_CH = ""; copy1 = WideCharToMultiByte(CP_ACP, WC_SEPCHARS, ClsName_T, -1, ClsName_CH, -1, NULL, NULL); // Initialize the application class WApplication WinApp(hInstance, ClsName_CH, MainWndProc); WinApp.Register(); // Create the main window WWindow Wnd; Wnd.Create(hInstance, ClsName_T, WndName); // Display the main window Wnd.Show(); // Process the main window's messages while ( GetMessage(&Msg, NULL, 0, 0) ) { TranslateMessage(&Msg); DispatchMessage(&Msg); } return 0; }
That got rid of the compiler errors relating to the conversions between the char variables, but another problem arose. When I tried to compile, I got "3 unresolved externals". They are:Code:WApplication::WApplication(HINSTANCE hInst, char *ClsName, WNDPROC WndPrc, LPCTSTR MenuName) { int copy1 = 0; LPCSTR ClsName_C = ClsName; LPWSTR ClsName_W; copy1 = MultiByteToWideChar(CP_ACP, WC_SEPCHARS, ClsName_C, -1, ClsName_W, 0); // Should add error handling code here in case the above returns zero. // Initializing the application using the application member variable _WndClsEx.cbSize = sizeof(WNDCLASSEX); _WndClsEx.style = CS_VREDRAW | CS_HREDRAW | CS_DBLCLKS; _WndClsEx.lpfnWndProc = WndPrc; _WndClsEx.cbClsExtra = 0; _WndClsEx.cbWndExtra = 0; _WndClsEx.hInstance = hInst; _WndClsEx.hIcon = LoadIcon(NULL, IDI_APPLICATION); _WndClsEx.hCursor = LoadCursor(NULL, IDC_ARROW); _WndClsEx.hbrBackground = static_cast<HBRUSH>(GetStockObject(WHITE_BRUSH)); _WndClsEx.lpszMenuName = MenuName; _WndClsEx.lpszClassName = ClsName_W; _WndClsEx.hIconSm = LoadIcon(NULL, IDI_APPLICATION); }
Exercise.obj : error LNK2019: unresolved external symbol "public: int __thiscall WWindow::Show(int)" (?Show@WWindow@@QAEHH@Z) referenced in function _WinMain@16
Exercise.obj : error LNK2019: unresolved external symbol "public: struct HWND__ * __thiscall WWindow::Create(struct HINSTANCE__ *,wchar_t const *,wchar_t const *,struct HWND__ *,unsigned long,unsigned long,int,int,int,int)" (?Create@WWindow@@QAEPAUHWND__@@PAUHINSTANCE__@@PB _W1PAU2@KKHHHH@Z) referenced in function _WinMain@16
Exercise.obj : error LNK2019: unresolved external symbol "public: __thiscall WWindow::WWindow(void)" (??0WWindow@@QAE@XZ) referenced in function _WinMain@16
Does anyone know how I can fix this problem? After looking around for a solution, I think I may need to include some libraries or something but I'm not sure how exactly.
Thanks.



LinkBack URL
About LinkBacks



