windows 对 GetStockObject@4 的未定义引用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1340824/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Undefined reference to GetStockObject@4
提问by Marcus Tik
I've created a program in Eclipse / MinGW / C (project type: C) which should just present an empty window. It also has the folowing line:
我在 Eclipse/MinGW/C(项目类型:C)中创建了一个程序,它应该只显示一个空窗口。它还具有以下行:
wndclassex.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
The call to GetStockObject()
produces a compiler error:
调用GetStockObject()
产生编译器错误:
Z:/mtsts_workspace/MTSTS/Debug/../WinMain.c:29: undefined reference to `GetStockObject@4'
Z:/mtsts_workspace/MTSTS/Debug/../WinMain.c:29: 未定义对`GetStockObject@4'的引用
Has anyone an idea what's wrong ?
有谁知道出了什么问题?
回答by unwind
Check the documentation, and make sure you link to the required libraries (-lgdi32
).
检查文档,并确保链接到所需的库 ( -lgdi32
)。
回答by Jon Bright
Best guess: you need to link gdi32.lib
.
最佳猜测:您需要链接gdi32.lib
.