I continually get errors such as "[Linker error] undefined reference to `GetStockObject@4'". What does it all mean? What does it mean when it says that and what can I do to take care of it?
I continually get errors such as "[Linker error] undefined reference to `GetStockObject@4'". What does it all mean? What does it mean when it says that and what can I do to take care of it?
Code:#include <iostream.h> int var; int test(); int main() { cout << "Please input your language:\n 1. C (C,C++,C#)\n 2. VB\n 3. Other\n"; cin >> var; return test(); } int test() { if(var == 1) { cout << "Y0u 4r3 t3h 1337\n"; system("PAUSE"); return main(); } else if(var == 2) { cout << "N00B3R!\n"; system("PAUSE"); return main(); } else if(var == 3) { cout << "You were not thought of.\n"; system("PAUSE"); return main(); } else { return 0; }}
@ ShadowMetis :
Please give some prog code, let's find out error?
It's pretty much directly from the book. That's why I'm scratch'n my head over it.
Code:#include <windows.h> LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM); int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { WNDCLASS WndClass; WndClass.style = 0; WndClass.cbClsExtra = 0; WndClass.cbWndExtra = 0; WndClass.lpfnWndProc = WndProc; WndClass.hInstance = hInstance; WndClass.hbrBackground = (HBRUSH) (COLOR_MENU+1); WndClass.hCursor = LoadCursor (NULL, IDC_ARROW); WndClass.hIcon = LoadIcon (NULL, IDI_APPLICATION); WndClass.lpszMenuName = 0; WndClass.lpszClassName = "WinProg"; RegisterClass(&WndClass); HWND hWindow; hWindow = CreateWindow("WinProg","WinSock Trial", WS_OVERLAPPEDWINDOW, 0,0,600,500,NULL,NULL, hInstance, NULL); ShowWindow (hWindow, nCmdShow); UpdateWindow (hWindow); MSG Message; while (GetMessage(&Message, NULL, 0, 0)); { DispatchMessage(&Message); } return (Message.wParam); } LRESULT CALLBACK WndProc (HWND hWnd, UINT uiMessage, WPARAM wParam, LPARAM lParam) { switch(uiMessage) { case WM_PAINT: HDC hdc; PAINTSTRUCT ps; hdc = BeginPaint (hWnd, &ps); HFONT hFont; hFont = (HFONT) GetStockObject (ANSI_FIXED_FONT); SelectObject(hdc, hFont); SetTextColor (hdc, RGB(0,0,180)); SetBkColor (hdc, RGB(190,180,200)); SetTextAlign (hdc, TA_LEFT); char *string1; string1 = new char[99]; lstrcpy (string1,"test test test test test test test test test test test test test test test test test test test test"); TextOut (hdc, 10, 40, string1, lstrlen(string1)); EndPaint (hWnd, &ps); case WM_DESTROY: PostQuitMessage(0); return 0; default: return DefWindowProc (hWnd, uiMessage, wParam, lParam); } }
[Linker error] undefined reference to `GetStockObject@4' [Linker error] undefined reference to `SelectObject@8'
[Linker error] undefined reference to `SetTextColor@8'
[Linker error] undefined reference to `SetBkColor@8'
[Linker error] undefined reference to `SetTextAlign@8'
[Linker error] undefined reference to `TextOutA@20'
It seems like it's only the GDI functions
Last edited by ShadowMetis; 08-17-2004 at 11:48 PM.
Code:#include <iostream.h> int var; int test(); int main() { cout << "Please input your language:\n 1. C (C,C++,C#)\n 2. VB\n 3. Other\n"; cin >> var; return test(); } int test() { if(var == 1) { cout << "Y0u 4r3 t3h 1337\n"; system("PAUSE"); return main(); } else if(var == 2) { cout << "N00B3R!\n"; system("PAUSE"); return main(); } else if(var == 3) { cout << "You were not thought of.\n"; system("PAUSE"); return main(); } else { return 0; }}
I'd still like to have my question answered...
Code:#include <iostream.h> int var; int test(); int main() { cout << "Please input your language:\n 1. C (C,C++,C#)\n 2. VB\n 3. Other\n"; cin >> var; return test(); } int test() { if(var == 1) { cout << "Y0u 4r3 t3h 1337\n"; system("PAUSE"); return main(); } else if(var == 2) { cout << "N00B3R!\n"; system("PAUSE"); return main(); } else if(var == 3) { cout << "You were not thought of.\n"; system("PAUSE"); return main(); } else { return 0; }}
Which compiler are you using?
Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah
You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie
It says right in the title that it's Dev-C++.........
Code:#include <iostream.h> int var; int test(); int main() { cout << "Please input your language:\n 1. C (C,C++,C#)\n 2. VB\n 3. Other\n"; cin >> var; return test(); } int test() { if(var == 1) { cout << "Y0u 4r3 t3h 1337\n"; system("PAUSE"); return main(); } else if(var == 2) { cout << "N00B3R!\n"; system("PAUSE"); return main(); } else if(var == 3) { cout << "You were not thought of.\n"; system("PAUSE"); return main(); } else { return 0; }}
I assume you created a project.
Go to project options
Make sure under type it is Win32 GUI
"Think not but that I know these things; or think
I know them not: not therefore am I short
Of knowing what I ought."
-John Milton, Paradise Regained (1671)
"Work hard and it might happen."
-XSquared
Originally Posted by JaWiB
its not mandatory to go to project options. just go to file
new project
windows application
and you should be set. For additonal functionality and options you can then go to project options. for example if you want to add an icon, provide additonal parameters etc.
Warning: Opinions subject to change without notice
The C Library Reference Guide
Understand the fundamentals
Then have some more fun
I was assuming he already made the project and just needed to change the settings...
"Think not but that I know these things; or think
I know them not: not therefore am I short
Of knowing what I ought."
-John Milton, Paradise Regained (1671)
"Work hard and it might happen."
-XSquared
I meant the compiler, not the GUI. I know of some people who use MSVC's compiler, and some who use the default MinGW32.Originally Posted by ShadowMetis
Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah
You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie