Hello. I'm currently building an application to solve a sort of game called Sudoku. I use Dev-C++. When I try to compile/link my program I get the following:

C:\C++\Sudoku\Sudoku.o(.text+0xe5) In function `ZSt13__cmath_powerIdET_S0_j':

[Linker error] undefined reference to `GetStockObject@4'

C:\C++\Sudoku\Sudoku.o(.text+0x4a1) In function `ZN6SudokuC1EP11HINSTANCE(int **)':

[Linker error] undefined reference to `GetStockObject@4'

[Linker error] undefined reference to `WinMain@16' C:\C++\Sudoku\Sudoku.o(.text+0x4a1) ld returned 1 exit status

C:\C++\Sudoku\Makefile.win [Build Error] [Sudoku.exe] Error 1

I know that the WinMain@16 means that I don't have a WinMain or Main method (see code below), but that is because it will be included later. On the other hand, I have no clue why I'm getting the "undefined reference" messages. So why do I get them and what do I do about them? Thank you.

CppMaster, may the code be with you

Here's my code:

Code://Sudoku.h #include<windows.h> #include<WinX.h> class Sudoku { private: static Sudoku current; int values[9][9];//if 0, the value is unknown bool constVals[9][9];//if true, value was given by user explicit Sudoku(HINSTANCE, int**); inline bool available(int, int, int); //for display purposes HWND mainWnd; HWND numFields[9][9]; HWND solveButton; void process(); public: Sudoku(){} Sudoku createSudoku(HINSTANCE, int**); void display(); bool solve(); void update(); static Sudoku currentSudoku(){ return current; } void setValues(int**); }; //Sudoku.cpp #include"Sudoku.h" #include<cctype> #include<cmath> Sudoku Sudoku::current; LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); int strToInt(char*, int, int index); char* intToStr(int); Sudoku::Sudoku(HINSTANCE hInst, int** vals) { for(int x = 0; x < 9 ; x++){ for(int y = 0; y < 9 ; y++){ if(vals) constVals[x][y] = true; values[x][y] = vals[x][y]; } } WNDCLASS wndclass; wndclass.style = CS_HREDRAW | CS_VREDRAW; wndclass.lpfnWndProc = WndProc; wndclass.cbClsExtra = 0; wndclass.cbWndExtra = 0; wndclass.hInstance = hInst; wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION); wndclass.hCursor = LoadCursor(NULL, IDC_ARROW); wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); wndclass.lpszMenuName = NULL; wndclass.lpszClassName = "SU_15_X"; if(!RegisterClass(&wndclass)) { MessageBox(NULL, TEXT("ERROR, could not register wndclass!"), "Sudoku", MB_ICONERROR); } int eBoxWidth = 27; int eBoxHeight = 27; int buttonWidth = 75; int buttonHeight = 40; mainWnd = CreateWindow("SU_15_X", TEXT("Sudoku"), WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, eBoxWidth*9, eBoxHeight*9 + buttonHeight, NULL, NULL, hInst, NULL); for(int x = 0; x < 27; x++){ for(int y = 0; y < 27; y++){ numFields[x][y] = CreateWindow("EDIT", NULL, WS_CHILD|WS_VISIBLE, x*27,y*27,eBoxWidth, eBoxHeight, mainWnd ,NULL,hInst,NULL); if(values[x][y] > 0)SetWindowText(numFields[x][y],TEXT(intToStr(values[x][y]))); } } solveButton = CreateWindow("BUTTON", TEXT("Solve"), BS_DEFPUSHBUTTON|WS_CHILD|WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, (int)((eBoxWidth*27 - buttonWidth)/2), (int)((eBoxHeight*27 - buttonHeight)/2), mainWnd, NULL, hInst, NULL); } Sudoku Sudoku::createSudoku(HINSTANCE hInst, int** vals) { Sudoku s = Sudoku(hInst, vals); Sudoku::current = s; return s; } bool Sudoku::solve() { bool test = false; for(int x = 0; x < 9; x++){ for(int y = 0, i; y < 9; y++){ if(values[x][y] > 0)continue; for(i = 1; i < 10; i++){ if(available(i, x, y)){ if(!test) test = true; else { test = false; break; } } } if(test) values[x][y] = i; } } return true; } bool Sudoku::available(int val, int row, int line) { if(row > 9) return false; if(line > 9) return false; for(int x = 0; x < 9; x++){ if(values[x][line] <= 0) continue; if(values[x][line] == val) return false; } for(int y = 0; y < 9; y++){ if(values[row][y] <= 0) continue; if(values[row][y] == val) return false; } for(int x = ((row - (row % 3)) / 3); x < 3; x++){ for(int y = ((line - (line % 3))/3); y < 3; y++){ if(values[x][y] <= 0) continue; if(values[x][y] == val) return false; } } return true; } LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { static Sudoku sudoku; switch(message) { case WM_CREATE: sudoku = Sudoku::currentSudoku(); return DefWindowProc(hWnd, message, wParam, lParam); case WM_COMMAND: sudoku.update(); sudoku.solve(); return 0; default: return DefWindowProc(hWnd, message, wParam, lParam); } } void Sudoku::update() { char number; for(int x = 0; x < 9; x++){ for(int y = 0; y < 0; y++){ if(GetWindowText(numFields[x][y], &number, 1)) values[x][y] = strToInt(&number, 1, 0); else values[x][y] = 0; } } } inline int strToInt(char* str, int length, int index) { int ans = 0; for(int i = length - 1; i > index - 1; i--){ if(!std::isdigit(str[i])) return (-1); ans += (((int)str[i]) - ((int)('0')))*int(pow(10,(i+1) - length)); } } inline char* intToStr(int i) { char* str = new char[12]; int temp = i; int length; for(length = 0; temp != 0; i++) temp = (int)(temp / 10); temp = i; int temp2 = 0; for(int j = length; j > 0; j--){ temp2 = (int)(temp/std::pow(10.0, j)); str += char(temp2 + (int)('0')); temp -= temp2*int(pow(10,j)); } return str; }