代码块graphics.h无法正常工作 [英] Codeblocks graphics.h not working

查看:75
本文介绍了代码块graphics.h无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我这样做时:

#include <graphics.h>

它说:

严重错误:graphics.h:没有此类文件或目录

fatal error: graphics.h: No such file or directory

该如何解决?

我正在使用代码块16.01

I'm using codeblocks 16.01

推荐答案

步骤1:从 http://winbgim.codecutter.org/或使用此链接.

第2步:提取下载的文件.您将获得三个文件:

Step 2: Extract the downloaded file. You’ll get three files:

graphics.h
winbgim.h
libbgi.a

第3步:将graphics.h和winbgim.h文件复制并粘贴到编译器目录的include文件夹中.(如果您在计算机的C驱动器中安装了Code :: Block,请执行以下操作:磁盘C>>程序文件>> CodeBlocks>> MinGW>> include .将这两个文件粘贴在那里.)

Step 3: Copy and paste graphics.h and winbgim.h files into the include folder of your compiler directory. (If you have Code::Blocks installed in C drive of your computer, go through: Disk C >> Program Files >> CodeBlocks >> MinGW >> include. Paste these two files there.)

第4步:将libbgi.a复制并粘贴到编译器目录的lib文件夹中.

Step 4: Copy and paste libbgi.a to the lib folder of your compiler directory.

第5步:打开Code :: Blocks.转到设置>>编译器链接器设置

Step 5: Open Code::Blocks. Go to Settings >> Compiler >> Linker settings

步骤6:在该窗口中,单击链接库"部分下的添加"按钮,然后浏览并选择在步骤4中复制到lib文件夹中的libbgi.a文件.

Step 6: In that window, click the Add button under the "Link libraries" part, and browse and select the libbgi.a file copied to the lib folder in step 4.

第7步:转到右侧的其他链接器选项",然后粘贴以下命令:

Step 7: Go to "Other linker options" on the right part and paste these commands:

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

第8步:确保正确执行第6步和第7步!这是前两个步骤的屏幕截图.然后,单击确定.

Step 8: Make sure you got steps 6 and 7 right! Here’s a screenshot of previous two steps. Then, click Ok.

Graphics.h in codeblocks - Compiler Settings
Global Compiler Settings >> Linker Settings

第9步:如果现在尝试使用C或C ++编译graphics.h程序代码,则仍然会出错.要解决此问题,请使用文本编辑器打开graphics.h文件(在步骤3中粘贴到include文件夹中).转到第302行,并用以下行替换该行:

Step 9: If you now try compiling a graphics.h program code in C or C++, you’ll still get error. To solve it, open graphics.h file (pasted in include folder in step 3) with text editor. Go to line number 302, and replace that line with this line:

"int left=0, int top=0, int right=INT_MAX, int bottom=INT_MAX"

如果正确(与上面相同),则保持原样

if it is correct(same as above) then leave it as it is

保存文件.完成!

现在,您可以编译任何包含 graphics. h头文件的C或C ++程序.如果编译C代码,您仍然会收到一条错误消息:致命错误:sstream:没有这样的文件目录" .对于此问题,如果文件扩展名是. c,请将其更改为 .cpp .

Now you can compile any C or C++ program containing graphics.h header file. If you compile C codes, you’ll still get an error saying: "fatal error: sstream : no such file directory". For this issue, if your file extension is .c, change it to .cpp.

这篇关于代码块graphics.h无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆