User forums > Help

undefined reference to `GetStockObject@4'|

<< < (4/5) > >>

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:

--- 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
--- End code ---
You can see that
--- Code: --- D:\CodeBlocks\MinGW\lib
--- End code ---
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.

Дмитро:
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


Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version