News:

The new Release 25.03 is out! You can download binaries for Windows and many major Linux distros here .

Main Menu

undefined reference to `GetStockObject@4'|

Started by Дмитро, October 18, 2019, 08:03:08 PM

Previous topic - Next topic

BlueHazzard

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:
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 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

Дмитро

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.

Дмитро

I am still carefully reading the answers, I have not seen the latter, and I will try.

oBFusCATed

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!]

Дмитро

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



oBFusCATed

Quote from: Дмитро on October 20, 2019, 08:20:45 PM
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!]