[ACCEPTED]-Undefined reference to GetStockObject@4-eclipse
Check the documentation, and make sure you link to the 1 required libraries (-lgdi32
).
Best guess: you need to link gdi32.lib
.
0
If your Win32 application is a non trivial 16 GUI you will need these link directives 15 to bring in the right libraries:
-lgdi32 -luser32 -lkernel32 -lcomctl32 -lm -mwindows
lgdi32
: graphics subsystemluser32
: user subsystemlkernel32
: kernel subsystemlcomctl32
: common control dll versionslm
: math librariesmwindows
: standalone GUI (console free) application
The above 14 directives tell the linker which libraries 13 to link; this is a different concept than 12 compiler header files which define the library 11 function prototypes (among other things). For 10 instance, declaring <math.h>
does not automatically 9 link the math lib; you need -lm
. Also, <wingdi.h>
does 8 not automatically link the gdi32 lib; you 7 need -lgdi32
.
At the command line you literally 6 specify -lgdi32
(along with others) after all your 5 file names. Otherwise, how you specify how 4 to link the various subsystem libraries 3 depends on the IDE you are using for the 2 specific build target you're working on. Check 1 your documentation for the IDE of choice.
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.