C++ 如何在代码块中使用 graphics.h?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20313534/
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
How to use graphics.h in codeblocks?
提问by Jefree Sujit
I have recently started learning graphics in C++.
我最近开始学习 C++ 中的图形。
I tried #include <graphics.h>
in my program in codeblocks but it shows error. Then I downloaded graphics.h
header from a site and pasted in the includefolder in codeblocks, yet it shows graphics.h:No such file or directory
.
我#include <graphics.h>
在代码块中尝试了我的程序,但它显示错误。然后我graphics.h
从一个站点下载了标题并将其粘贴到代码块中的包含文件夹中,但它显示graphics.h:No such file or directory
.
Can anyone teach me how to use graphics.h
in codeblocks?
谁能教我如何graphics.h
在代码块中使用?
回答by Dinesh Subedi
- First download WinBGIm from http://winbgim.codecutter.org/Extract it.
- Copy
graphics.h
andwinbgim.h
files in include folder of your compiler directory - Copy
libbgi.a
to lib folder of your compiler directory - In code::blocks open Settings >> Compiler and debugger >>linker settings
click Add button in link libraries part and browse and select
libbgi.a
file - In right part (i.e. other linker options) paste commands
-lbgi -lgdi32 -lcomdlg32 -luuid -loleaut32 -lole32
- Click OK
- 首先从http://winbgim.codecutter.org/下载 WinBGIm解压。
- 在编译器目录的包含文件夹中复制
graphics.h
和winbgim.h
文件 - 复制
libbgi.a
到编译器目录的 lib 文件夹 - 在代码::块中打开设置>>编译器和调试器>>链接器设置单击链接库部分中的添加按钮并浏览并选择
libbgi.a
文件 - 在右侧(即其他链接器选项)粘贴命令
-lbgi -lgdi32 -lcomdlg32 -luuid -loleaut32 -lole32
- 单击确定
For detail information follow this link.
有关详细信息,请访问此链接。
回答by John WH Smith
You don't only need the header file, you need the library that goes with it. Anyway, the include
folder is not automatically loaded, you must configure your project to do so. Right-click on it : Build options
> Search directories
> Add
. Choose your include
folder, keep the path relative.
您不仅需要头文件,还需要与之配套的库。无论如何,该include
文件夹不会自动加载,您必须配置您的项目才能这样做。右键单击它:Build options
> Search directories
> Add
。选择您的include
文件夹,保持路径相对。
EditFor further assistance, please give details about the library you're trying to load (which provides a graphics.h
file.)
编辑如需进一步帮助,请提供有关您尝试加载的库(提供graphics.h
文件)的详细信息。
回答by nim
AFAIK, in the epic DOS era there is a header file named graphics.h shipped with Borland Turbo C++ suite. If it is true, then you are out of luck because we're now in Windows era.
AFAIK,在史诗般的 DOS 时代,Borland Turbo C++ 套件附带了一个名为 graphics.h 的头文件。如果这是真的,那么你就不走运了,因为我们现在处于 Windows 时代。
回答by Aditya Ankur
- Open the file graphics.h using either of Sublime Text Editor or
Notepad++,from the
include
folder where you have installed Codeblocks. - Goto line no 302
- Delete the line and paste
int left=0, int top=0, int right=INT_MAX, int bottom=INT_MAX,
in that line. - Save the file and start Coding.
- 使用 Sublime Text Editor 或 Notepad++,从
include
您安装 Codeblocks的文件夹中打开文件 graphics.h 。 - 转到第 302 行
- 删除该行并粘贴
int left=0, int top=0, int right=INT_MAX, int bottom=INT_MAX,
到该行中。 - 保存文件并开始编码。
回答by Mukesh M
If you want to use Codeblocks and Graphics.h,you can use Codeblocks-EP(I used it when I was learning C in college) then you can try
如果你想用Codeblocks和Graphics.h,你可以用Codeblocks-EP(我在大学学C的时候用过)然后你可以试试
Codeblocks-EP http://codeblocks.codecutter.org/
Codeblocks-EP http://codeblocks.codecutter.org/
In Codeblocks-EP , [File]->[New]->[Project]->[WinBGIm Project]
在 Codeblocks-EP 中,[File]->[New]->[Project]->[WinBGIm Project]
It has templates for WinBGIm projects installed and all the necessary libraries pre-installed.
它安装了 WinBGIm 项目的模板并预先安装了所有必要的库。
OR try this https://stackoverflow.com/a/20321173/5227589