This guide will help you set up the graphics.h library in Dev-C++ for simple graphical programs. Please note that graphics.h works best with a 32-bit compiler.
- Dev-C++ (32-bit): Ensure you have the 32-bit version of Dev-C++ installed.
-
Download Required Files
- Download
graphics.handlibbgi.a.
- Download
-
Copy Files to Appropriate Directories
- Place
graphics.hin:C:\Program Files (x86)\Dev-Cpp\MinGW32\include - Place
libbgi.ain:C:\Program Files (x86)\Dev-Cpp\MinGW32\lib
- Place
-
Update Linker Settings
- Open Dev-C++ and go to Tools > Compiler Options.
- Under the "Linker" section, add the following flags:
-lbgi -lgdi32 -lcomdlg32 -luuid -loleaut32 -lole32
-
Test with a Sample Program
- Use the following program to test your setup:
#include <graphics.h> #include <conio.h> int main() { int gd = DETECT, gm; initgraph(&gd, &gm, ""); circle(200, 200, 100); getch(); closegraph(); return 0; }
- Compile and run the program.
- Use the following program to test your setup:
- Switch to a 32-Bit Compiler: The
graphics.hlibrary is not compatible with 64-bit compilers. Make sure you use the 32-bit version of Dev-C++ or a similar environment. - Consider Modern Alternatives: For better performance and support, consider switching to modern libraries like SFML, SDL2, or Raylib.
If you encounter any issues, feel free to raise them in this repository!