简体   繁体   English

c++ graphics.h -lbgi not found

[英]c++ graphics.h -lbgi not found

I have this code:我有这个代码:

#include<graphics.h>
int main( )
{
    initwindow( 700 , 700 , "MY First Program");
    circle(200, 200, 150);
    getch();
    return 0;
}

but I get this error:但我收到此错误:

ld||cannot find -lbgi|
||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

I added it to linker options and also the other things.我将它添加到链接器选项以及其他内容中。

What should I do?我该怎么办?

Download this and put it in your C compiler's lib folder.下载并将其放在 C 编译器的lib文件夹中。 Also do not forget to add in the linkers:也不要忘记添加链接器:

-lbgi
-lgdi32
-lcomdlg32
-luuid
-loleaut32
-lole32

After doing above, you would get the actual compile error belonging to initgraph() or other.完成上述操作后,您将获得属于initgraph()或其他的实际编译错误。

It is worked for me in Codeblocks 13.12.它在 Codeblocks 13.12 中对我有用。

If you are coding in C++11, You must know that <graphics.h> is deprecated in C++11.如果您使用 C++11 进行编码,您必须知道<graphics.h>在 C++11 中已被弃用。 If you are compiling it in Turbo C++, you must use the initgraph() function and give the path to the BGI folder.如果你用 Turbo C++ 编译它,你必须使用initgraph()函数并给出 BGI 文件夹的路径。 For more details, check this out: http://www.programmingsimplified.com/c/graphics.h有关更多详细信息,请查看: http : //www.programmingsimplified.com/c/graphics.h

You must include the initgraph() function.您必须包含initgraph()函数。 Add this:添加这个:

int gd=DETECT,gm;
initgraph(&gd,&gm,"c:\\TC\BGI"); //Path where BGI folder appears

Perhaps your default location of compiler is not under ide folder.也许您的编译器的默认位置不在 ide 文件夹下。 In this situation you have to copy graphics.h and winbgim.h in include folder and libbgi in lib folder of default location of the compiler also which may be C:\\MinGW\\include and C:\\MinGW\\lib.在这种情况下,您必须将包含文件夹中的 graphics.h 和 winbgim.h 和编译器默认位置 lib 文件夹中的 libbgi 复制,也可能是 C:\\MinGW\\include 和 C:\\MinGW\\lib。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM