tags:

views:

135

answers:

2

I've created a program in Eclipse / MinGW / C (project type: C) which should just present an empty window. It also has the folowing line:

wndclassex.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);

The call to GetStockObject() produces a compiler error:

Z:/mtsts_workspace/MTSTS/Debug/../WinMain.c:29: undefined reference to `GetStockObject@4'

Has anyone an idea what's wrong ?

+4  A: 

Check the documentation, and make sure you link to the required libraries (gdi32).

unwind
I have included windows.h And with Visual Studio the code was OK.
FunnyBoy
Including doesn't help; this is a link-type error. You need to specify that the code should be linked with gdi32.lib, where the actual code for GetStockObject() resides.
unwind
How can I "specify the code" that should be linked with gdi32.lib ???Normaly I just put in the #include's and then simply call the functions ...
FunnyBoy
Add the library gdi32.lib to your Eclipse project.
unwind
+2  A: 

Best guess: you need to link Gdi32.lib.

Jon Bright