这个问题在这里已经有了答案:
What is an undefined reference/unresolved external symbol error and how do I fix it?
(37 个回答)
4年前关闭。
我在使用 readimagefile 函数的 Dev C++ 中遇到错误。
每当我尝试使用头文件“graphics.h”中包含的函数时,它都会显示“未定义对 readimagefile 的引用”。这是我显示图像的代码:
int main()
{
initwindow(600,600,"Trial");
readimagefile("alpha.jpg",0,0,500,500);
getch();
return 0;
}
如果有人可以为我提供其更正或替代代码以显示图像,那将非常有帮助。
另外,如果我输入此图像,我可以将其用作背景吗?如果不是,那么在 C++ 中导入图像作为背景的最佳方法是什么。
我见过很多人寻求帮助,这很公平,这些错误不会出现在其他编译器上,比如代码块或 Visual Studio,但我必须使用 Dev C++,所以请确保你的代码适用于 Dev C++。
最佳答案
I try to use the function included in the header file 'graphics.h'
假设您发布了整个文件 - 您需要添加
#include "graphics.h"
如果要使用其中的函数,请在 cpp 文件的顶部。此外,您似乎正在尝试使用 WinBGIm - 不要忘记检查您是否从他们的installation guide 中执行了每一步。 - 尤其是 关于所需链接器命令的部分:
-lbgi
-lgdi32
-lcomdlg32
-luuid
-loleaut32
-lole32
关于c++ - 如何解决在开发 C++ 中未定义的对 readimagefile 的引用错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49219815/