Undefined link to GetStockObject @ 4

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

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

      

The call GetStockObject()

throws a compiler error:

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

Does anyone know what is wrong?

+2


source to share


2 answers


Check the documentation and make sure you link with the required libraries ( -lgdi32

).



+7


source


Best guess: you need to link gdi32.lib

.



+3


source







All Articles