How to use graphics.h in code blocks?

Recently, I began to study graphics in C ++.

I tried #include <graphics.h> in my program in code blocks, but it shows an error. Then I downloaded the graphics.h header from the site and pasted it into the include folder in the code blocks, but it shows graphics.h:No such file or directory .

Can someone teach me how to use graphics.h in code blocks?

+7
c ++ codeblocks graphics
source share
5 answers
  • First download WinBGIm from http://winbgim.codecutter.org/ Extract it.
  • Copy the graphics.h and winbgim.h files to the include folder of your compiler directory
  • Copy libbgi.a to the lib folder of your compiler directory
  • In the code :: blocks, open Settings β†’ Compiler and debugger β†’ linker settings, click the Add button in the link libraries section and browse and select the libbgi.a file
  • On the right side (for example, other linker options) insert -lbgi -lgdi32 -lcomdlg32 -luuid -loleaut32 -lole32
  • Click OK

See below for more details.

+11
source share

You need not only the header file, you need the library that comes with it. In any case, the include folder does not load automatically; you must configure your project for this. Right-click on it: Build options > Search directories > Add . Select the include folder, save the path relatively.

Change For more information, please provide details of the library you are trying to download (which provides the graphics.h file.)

+3
source share

AFAIK, in the DOS era, there is a header file called graphics.h that comes with Borland Turbo C ++. If this is true, then you are out of luck, because we are now in the Windows era.

+3
source share
  • Open the graphics.h file using any of the Sublime Text Editor or Notepad ++, from the include folder in which you installed CodeBlocks.
  • Go to line number 302
  • Delete the line and insert int left=0, int top=0, int right=INT_MAX, int bottom=INT_MAX, in this line.
  • Save the file and run the encoding.
+2
source share

If you want to use Codeblocks and Graphics.h, you can use Codeblocks-EP (I used it when I studied C in college), then you can try

Codeblocks-EP http://codeblocks.codecutter.org/

In Codeblocks-EP, [File] β†’ [New] β†’ [Project] β†’ [WinBGIm Project]

Codeblocks-EP WinBGIm Project Graphics.h

It has templates for installed WinBGIm projects and pre-installed all the necessary libraries.

OR try overflow https://stackoverflow.com/a/4648778

+1
source share

All Articles