shailendra - 2018-08-19

//Code listing for WMain.cpp

include <windows.h></windows.h>

extern LRESULT CALLBACK WindowF (HWND,UINT,WPARAM,LPARAM);
char szWinName[] = "MyWin";
char szTitle[] = "Parabola Drawing";

int WINAPI WinMain (HINSTANCE hThisInst, HINSTANCE hPrevInst,
LPSTR lpszArgs, int nWinMode)
{
//Defining window class
HWND hwnd;
MSG msg;
WNDCLASSEX wcl;

wcl.cbClsExtra = 0;//extra bytes
wcl.cbSize = sizeof(WNDCLASSEX); //size of the struct
wcl.cbWndExtra = 0;//extra bytes
wcl.hbrBackground = (HBRUSH)GetStockObject(WHITEBRUSH);
wcl.hCursor = LoadCursor(NULL,IDC_ARROW);
wcl.hIcon = LoadIcon(NULL,IDI_WINLOGO);
wcl.hIconSm = NULL;
wcl.hInstance = hThisInst;
wcl.lpfnWndProc = WindowF;
wcl.lpszClassName = szWinName;
wcl.lpszMenuName = "MyMenu";
wcl.style = 0;

//Registration of class
if(!RegisterClassEx(&wcl))
return 0;

//Create Window
hwnd = CreateWindow(
szWinName,
szTitle,
WS_OVERLAPPEDWINDOW|WS_SYSMENU,// no scroll bar
CW_USEDEFAULT,
CW_USEDEFAULT,
400, // specific value instead of CW_USEDEFAULT
300, // specific value instead of CW_USEDEFAULT
HWND_DESKTOP,
NULL,
hThisInst,
NULL
);

ShowWindow(hwnd, SW_RESTORE);
UpdateWindow(hwnd);

//Serve Messages
while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}//end while
return msg.wParam;
}//end WinMain****

the above is code im trying to compile on dev c++ but it says following

> Compiling single file...

  • Filename: E:\study\sem7\graphics lab\P4_2_Ellipse\WMain.cpp
  • Compiler Name: TDM-GCC 4.9.2 64-bit Debug

Processing C++ source file...

  • C++ Compiler: C:\Program Files (x86)\Dev-Cpp\MinGW64\bin\g++.exe
  • Command: g++.exe "E:\study\sem7\graphics lab\P4_2_Ellipse\WMain.cpp" -o "E:\study\sem7\graphics lab\P4_2_Ellipse\WMain.exe" -g3 -I"C:\Program Files (x86)\Dev-Cpp\MinGW64\include" -I"C:\Program Files (x86)\Dev-Cpp\MinGW64\x86_64-w64-mingw32\include" -I"C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include" -I"C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++" -L"C:\Program Files (x86)\Dev-Cpp\MinGW64\lib" -L"C:\Program Files (x86)\Dev-Cpp\MinGW64\x86_64-w64-mingw32\lib" -static-libgcc -g3
    C:\Users\SHAILE~1\AppData\Local\Temp\ccRh648e.o: In function WinMain': E:/study/sem7/graphics lab/P4_2_Ellipse/WMain.cpp:19: undefined reference toimp_GetStockObject'
    C:\Users\SHAILE~1\AppData\Local\Temp\ccRh648e.o:WMain.cpp:(.rdata$.refptr._Z7WindowFP6HWND
    jyx[.refptr._Z7WindowFP6HWND__jyx]+0x0): undefined reference to `WindowF(HWND__*, unsigned int, unsigned long long, long long)'
    collect2.exe: error: ld returned 1 exit status

Compilation results...

  • Errors: 1
  • Warnings: 0
  • Compilation Time: 1.24s

the code compiles and runs fine in codeblocks

the problem is with line " wcl.hbrBackground = (HBRUSH)GetStockObject(WHITEBRUSH);"
but how to resolve it please help me .