Author Topic: undefined reference to `GetStockObject@4'|  (Read 20376 times)

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: undefined reference to `GetStockObject@4'|
« Reply #15 on: October 20, 2019, 12:30:45 pm »
The linker thinks "D:\CodeBlocks\MinGW\lib" is a library, but it is not. It is a folder.
You have to add the folder where the libraries are in
Project->Build options->Search directories->Linker
and the libraries only with name in 
Project->Build options->Search directories->Linker settings->Link libraries

Do not add any library settings in "Project->Build options->Search directories->Linker settings->Other linker options"
or if you do keep atention that "-L" is for folders and "-l" is for libraries

in the line posted by stahta01:
Code
mingw32-g++.exe -LG:\SDL\SDL-devel-1.2.15-mingw32\SDL-1.2.15\lib -LG:\SDK\Lib -LD:\CodeBlocks\MinGW\lib -o bin\Debug\WindowMain_0.exe obj\Debug\WindowMain_0.o -lmingw32 -lSDLmain -lSDL D:\CodeBlocks\MinGW\lib
You can see that
Code
 D:\CodeBlocks\MinGW\lib
has no option prefix ("-L" or "-l") so you have posted this in one place where you should not...

[Edit:] ok, someone was quicker, but i post it anyway

Offline Дмитро

  • Multiple posting newcomer
  • *
  • Posts: 107
Re: undefined reference to `GetStockObject@4'|
« Reply #16 on: October 20, 2019, 01:25:24 pm »
Yes Yes. Of course, I deleted it. Thank! But I get an undefined reference error to `GetStockObject @ 4 '|. I experimented with the settings for about half an hour, and did not succeed in compiling.

Offline Дмитро

  • Multiple posting newcomer
  • *
  • Posts: 107
Re: undefined reference to `GetStockObject@4'|
« Reply #17 on: October 20, 2019, 01:26:55 pm »
I am still carefully reading the answers, I have not seen the latter, and I will try.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: undefined reference to `GetStockObject@4'|
« Reply #18 on: October 20, 2019, 01:36:55 pm »
Go to this page: https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-getstockobject
Scroll to the bottom, read the "Requirements", add the required libraries to your linker settings.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Дмитро

  • Multiple posting newcomer
  • *
  • Posts: 107
Re: undefined reference to `GetStockObject@4'|
« Reply #19 on: October 20, 2019, 08:20:45 pm »
Yes, I compiled it!! Hurray!! Helped understand the last message.(no last, Posts: 2502)
In general, thank you all very much.
My settings:
Project->Build options->Linker settings->Link libraries    libgdi32.a
Project->Build options->Search directories->Linker   D:\CodeBlocks\MinGW\lib



Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: undefined reference to `GetStockObject@4'|
« Reply #20 on: October 21, 2019, 03:15:41 am »
Project->Build options->Linker settings->Link libraries    libgdi32.a
This should be just gdi32!
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]