使用 <graphics.h> Turbo C++ 时 C 中的链接器错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21111065/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-27 23:29:11  来源:igfitidea点击:

Linker error in C. while using <graphics.h> Turbo C++

c++clinkerturbo-c++

提问by MELWIN

I have entered the following code in turbo c++.

我在turbo c++ 中输入了以下代码。

    #include<graphics.h>
    #include<conio.h>
    int main()
    {
    int gd= DETECT, gm;
    initgraph(&gd,&gm,"D:\TC\BGI");
    getch();
    closegraph();
    return 0;
    }

It compiles without any errors and warning. But when I run the program the following errors are displayed

它编译时没有任何错误和警告。但是当我运行程序时显示以下错误

  • Linker Error: Undefined symbol_closegraph in module G1.C
  • Linker Error: Undefined symbol_initgraph in module G1.C
  • 链接器错误:模块 G1.C 中未定义的 symbol_closegraph
  • 链接器错误:模块 G1.C 中未定义的 symbol_initgraph

note : The BGI folder is in the path D:\TC\

注意:BGI 文件夹在路径 D:\TC\

How can I solve the problem, please help me so I could begin useing graphics in C.

我该如何解决这个问题,请帮助我,以便我可以开始在 C 中使用图形。

回答by Digital_Reality

If you are using Turbo C .. just need to check one option:

如果您使用 Turbo C .. 只需要检查一个选项:

Go to Options->Linker->Librariesand check the Graphics Library option

转到Options->Linker->Libraries并检查图形库选项

回答by Ash

Go to options>>linker>>librariesand instead of:

转到options>>linker>>libraries和而不是:

initgraph(&gd,&gm,"");

Write:

写:

initgraph(&gd,&gm,"..\BGI);