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

Offline Дмитро

  • Multiple posting newcomer
  • *
  • Posts: 107
undefined reference to `GetStockObject@4'|
« on: October 18, 2019, 08:03:08 pm »
Hello Hello everyone! My codeblocks gave the error. undefined reference to `GetStockObject@4'| What is it? How to solve it, what to do to fix it? :'(

Code: mysql
wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1553

Offline Дмитро

  • Multiple posting newcomer
  • *
  • Posts: 107
Re: undefined reference to `GetStockObject@4'|
« Reply #2 on: October 18, 2019, 08:38:54 pm »
Yes, I find in myself really. D:\CodeBlocks\MinGW\lib\libgdi32.a

Offline Дмитро

  • Multiple posting newcomer
  • *
  • Posts: 107
Re: undefined reference to `GetStockObject@4'|
« Reply #3 on: October 18, 2019, 09:22:59 pm »
I am running Code::Blocks version 17ю12 on windows
(version 7). The compiler I use is MinGW
version 5.1.0.

Offline Дмитро

  • Multiple posting newcomer
  • *
  • Posts: 107
Re: undefined reference to `GetStockObject@4'|
« Reply #4 on: October 18, 2019, 09:28:53 pm »
What settings kodeblocksiv should be performed to correctly find libgdi32.a? How is it before, for years, I have not met the problem of finding ordinary libraries?

Offline Дмитро

  • Multiple posting newcomer
  • *
  • Posts: 107
Re: undefined reference to `GetStockObject@4'|
« Reply #5 on: October 18, 2019, 09:33:57 pm »
||error: :\CodeBlocks\MinGW\lib: Invalid argument|

Offline Дмитро

  • Multiple posting newcomer
  • *
  • Posts: 107
Re: undefined reference to `GetStockObject@4'|
« Reply #6 on: October 18, 2019, 09:37:14 pm »
ld.exe||cannot find D:\CodeBlocks\MinGW\lib: Permission denied|

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: undefined reference to `GetStockObject@4'|
« Reply #7 on: October 18, 2019, 09:58:59 pm »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline Дмитро

  • Multiple posting newcomer
  • *
  • Posts: 107
Re: undefined reference to `GetStockObject@4'|
« Reply #8 on: October 19, 2019, 09:37:44 am »
Yes, I am still unable to resolve this issue, unable to understand where there are troubles.
« Last Edit: October 19, 2019, 09:45:02 am by Дмитро »

Offline Дмитро

  • Multiple posting newcomer
  • *
  • Posts: 107
Re: undefined reference to `GetStockObject@4'|
« Reply #9 on: October 19, 2019, 09:47:06 am »
Have I provided all the necessary information and information?
« Last Edit: October 19, 2019, 11:28:29 am by Дмитро »

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: undefined reference to `GetStockObject@4'|
« Reply #10 on: October 19, 2019, 11:29:37 am »
What is in "D:\CodeBlocks\MinGW\lib"?
have you added it by yourself?

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: undefined reference to `GetStockObject@4'|
« Reply #11 on: October 19, 2019, 06:07:27 pm »
Do not tell the linker to look for libraries in a folder that does not exist!

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

Edit: If the folder does exist, then remove the folder from the "other linker options".

Tim S.
« Last Edit: October 19, 2019, 06:18:38 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline Дмитро

  • Multiple posting newcomer
  • *
  • Posts: 107
Re: undefined reference to `GetStockObject@4'|
« Reply #12 on: October 20, 2019, 12:02:18 pm »
No, it's still not clear to me how to fix the error.

Actually, the one needed on the computer was originally, is, and has its own address D: \ CodeBlocks \ MinGW \ lib inside this folder.
Also, there are many other libs, for example libvideoprt.a, and so on, about 144 libs.

For a long time, actually years earlier, I did not carefully consider this.
Added only other third-party inclusions and libs.

In addition, there are also D: \ CodeBlocks \ MinGW \ bin paths, inside which there are compilers and some many dlls.
And there is also a path and a folder D: \ CodeBlocks \ MinGW \ include, with various inclusions inside it, and in it there are subfolders
D: \ CodeBlocks \ MinGW \ include \ GL, D: \ CodeBlocks \ MinGW \ include \ sys, D: \ CodeBlocks \ MinGW \ include \ gdiplus, D: \ CodeBlocks \ MinGW \ include \ ddk also containing inclusions too.

Also along the path D: \ CodeBlocks \ MinGW \ libexec \ gcc \ mingw32 \ 5.1.0 also with programs and containing dll and for example collect2.exe, and deeper inside this folder there is also a folder D: \ CodeBlocks \ MinGW \ libexec \ gcc \ mingw32 \ 5.1.0 \ install-tools containing fixincl.exe and files.
Also along the path D: \ CodeBlocks \ MinGW \ lib \ gcc \ mingw32 \ 5.1.0 there are many .a libraries, among them, for example, libatomic.a, one file libstdc .dll.a-gdb.py, several .o, inside this folder also contains the folder D: \ CodeBlocks \ MinGW \ lib \ gcc \ mingw32 \ 5.1.0 \ include containing a lot of .h files, for example avx512bwintrin.h, and inside it the folder D: \ CodeBlocks \ MinGW \ lib \ gcc \ mingw32 \ 5.1.0 \ include \ c, which also contains many folders, many files, and many complex nesting levels inside.
Here inside
d: \ CodeBlocks \ MinGW \ lib \ gcc \ mingw32 \ 5.1.0 \ include \ c \ tr2 \
d: \ CodeBlocks \ MinGW \ lib \ gcc \ mingw32 \ 5.1.0 \ include \ c \ tr1 \
d: \ CodeBlocks \ MinGW \ lib \ gcc \ mingw32 \ 5.1.0 \ include \ c \ profile \
d: \ CodeBlocks \ MinGW \ lib \ gcc \ mingw32 \ 5.1.0 \ include \ c \ parallel \
d: \ CodeBlocks \ MinGW \ lib \ gcc \ mingw32 \ 5.1.0 \ include \ c \ mingw32 \
d: \ CodeBlocks \ MinGW \ lib \ gcc \ mingw32 \ 5.1.0 \ include \ c \ ext \
d: \ CodeBlocks \ MinGW \ lib \ gcc \ mingw32 \ 5.1.0 \ include \ c \ experimental \
d: \ CodeBlocks \ MinGW \ lib \ gcc \ mingw32 \ 5.1.0 \ include \ c \ decimal \
d: \ CodeBlocks \ MinGW \ lib \ gcc \ mingw32 \ 5.1.0 \ include \ c \ debug \
d: \ CodeBlocks \ MinGW \ lib \ gcc \ mingw32 \ 5.1.0 \ include \ c \ bits \
d: \ CodeBlocks \ MinGW \ lib \ gcc \ mingw32 \ 5.1.0 \ include \ c \ backward \

Still everywhere around and inside and also in the depths and everywhere there are many and especially many folders, subfolders and everywhere there are many complicated folders and paths.
I'm reviewing and studying at this moment, I was a little surprised at the many complexity of the structure of subfolders.



And now, of course, I want to configure my codeblocks always so that it works always correctly and has a good one.

Offline Дмитро

  • Multiple posting newcomer
  • *
  • Posts: 107
Re: undefined reference to `GetStockObject@4'|
« Reply #13 on: October 20, 2019, 12:07:26 pm »
In short, all the specified folders are there, the paths are correct. There is a necessary lib. I can’t, I don’t know how to set the correct settings for codeblocks. His work as a whole suits me, except for the moment indicated in the title of the topic.

Offline gd_on

  • Lives here!
  • ****
  • Posts: 796
Re: undefined reference to `GetStockObject@4'|
« Reply #14 on: October 20, 2019, 12:27:49 pm »
as told by stahta01 the problem comes certainly from this :
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 set D:\CodeBlocks\MinGW\lib twice.

the first -LD:\CodeBlocks\MinGW\lib tell the linker where to find some libraries (-L option). This is probably good.
but the last one D:\CodeBlocks\MinGW\lib is certainly wrong. You have probably introduced this somewhere in your settings (other settings probably). Delete that wrong setting.

gd_on
Windows 11 64 bits (23H2), svn C::B (last version or almost!), wxWidgets 3.2.4 (tests with 3.3), Msys2 Compilers 13.2.0, 64 bits (seh, posix : gcc, g++ and gfortran in C:\msys64\mingw64) or 32 bits (dwarf2, posix  in C:\msys64\mingw32).