Setup Guide

How to Run graphics.h Programs

graphics.h is a legacy C/C++ graphics library from the Borland BGI era, still widely used in university computer graphics labs. Running it on modern systems can be frustrating. This guide covers five different methods — from zero-setup online tools to traditional desktop IDEs — so you can pick the one that works best for you.

Published June 20, 2026 · 10 min read

What is graphics.h?

graphics.h is a C/C++ header file that provides simple functions for drawing shapes, lines, circles, text, and colors on screen. It was originally part of the Borland Graphics Interface (BGI) included with Turbo C/C++ in the late 1980s and early 1990s.

Despite being over three decades old, graphics.h is still widely used in computer graphics lab courses at universities across India and other countries. Functions like initgraph(), circle(), line(), rectangle(), and closegraph() are standard in these courses.

The problem? graphics.h was designed for 16-bit DOS. It does not work natively on modern 64-bit operating systems like Windows 10/11, macOS, or Linux. That is why setting it up can be so frustrating — and why students often spend more time configuring their environment than actually learning graphics programming.

Below are five ways to run graphics.h programs, ordered from easiest to most complex.

Classic

Method 3: Turbo C++ with DOSBox

Turbo C++ is the original IDE that ships with graphics.h. Since it is a 16-bit DOS application, it cannot run natively on modern 64-bit Windows. You need DOSBox (a DOS emulator) to run it.

Steps

  1. Download Turbo C++ 3.0 (commonly available as a zip archive from educational sites).
  2. Download and install DOSBox.
  3. Extract the Turbo C++ folder to a location like C:\TURBOC3.
  4. Open DOSBox and mount the drive:
    mount c c:\TURBOC3
    c:
    cd BIN
    TC.EXE
  5. Write your program in the Turbo C++ editor and press Ctrl+F9 to compile and run.
  6. Press Alt+F5 to view the graphics output.

Known problems

  • Outdated editor: The Turbo C++ editor has no syntax highlighting, no autocomplete, no tabs, and no undo history. It uses a tiny fixed-resolution window that is difficult to use on modern high-DPI screens.
  • DOSBox issues: Screen resolution scaling glitches, fullscreen problems, and mouse capture issues are common.
  • No modern features: No autosave, no file tree, no copy-paste from external sources.
  • Path errors: The BGI path (C:\\TURBOC3\\BGI) must be set correctly in initgraph() or the program will crash.

✓ Pros

  • Uses the original Turbo C compiler
  • 100% compatibility with graphics.h
  • Works offline

✗ Cons

  • Extremely outdated editor
  • DOSBox setup is confusing
  • Resolution and scaling issues
  • No modern editing features
  • Only works on Windows
Alternative

Method 4: Dev-C++ with WinBGIm

Dev-C++ is a free C/C++ IDE for Windows. It does not include graphics.h by default, but you can add it using the WinBGIm library — a Windows port of the Borland Graphics Interface.

Steps

  1. Download and install Dev-C++ (Orwell or Embarcadero edition).
  2. Download the WinBGIm library files: graphics.h, winbgim.h, and libbgi.a.
  3. Copy graphics.h and winbgim.h into the Dev-C++ MinGW64\include folder.
  4. Copy libbgi.a into the Dev-C++ MinGW64\lib folder.
  5. Create a new project in Dev-C++ (File → New → Project).
  6. Go to Project → Project Options → Parameters → Linker and add:
    -lbgi -lgdi32 -lcomdlg32 -luuid -loleaut32 -lole32
  7. Write your program, save it as .cpp, and compile with F11.

Important notes

  • Always create a project, not a single file. Linker settings are project-level.
  • Use a 32-bit compiler (TDM-GCC 32-bit) — the WinBGIm library may not work with 64-bit compilers.
  • Use initwindow(800, 600) instead of initgraph() with a BGI path for easier setup.
  • Some graphics.h functions behave slightly differently under WinBGIm compared to the original Turbo C implementation.

✓ Pros

  • Free and lightweight IDE
  • Runs natively on Windows
  • Better editor than Turbo C
  • Works offline

✗ Cons

  • Manual file and linker setup
  • Must use 32-bit compiler
  • WinBGIm is not 100% compatible
  • Windows only
  • Linker flag errors are common
Alternative

Method 5: Code::Blocks with WinBGIm

Code::Blocks is another free C/C++ IDE. Like Dev-C++, it requires the WinBGIm library to support graphics.h.

Steps

  1. Download and install Code::Blocks (with MinGW bundled).
  2. Download the WinBGIm files: graphics.h, winbgim.h, and libbgi.a.
  3. Copy graphics.h and winbgim.h to the Code::Blocks MinGW\include folder.
  4. Copy libbgi.a to the Code::Blocks MinGW\lib folder.
  5. Open Code::Blocks and go to Settings → Compiler → Linker settings.
  6. Click Add and browse to the libbgi.a file.
  7. In Other linker options, paste:
    -lbgi -lgdi32 -lcomdlg32 -luuid -loleaut32 -lole32
  8. Click OK. Create a new project, write your program as .cpp, and compile.

Important notes

  • Always save files with the .cpp extension, not .c.
  • If you encounter errors in graphics.h around line 302, you may need to manually edit the header file (known WinBGIm bug on newer compilers).
  • Ensure your MinGW installation path is correctly set under Settings → Compiler → Toolchain executables.

✓ Pros

  • Free and feature-rich IDE
  • Better project management
  • Active community support
  • Works offline

✗ Cons

  • Manual setup required
  • WinBGIm compatibility issues
  • Header file bugs on newer compilers
  • Windows only
  • Confusing for beginners

Comparison table

Here is a side-by-side comparison of all five methods:

Feature Online Compiler VS Code Extension Turbo C++ Dev-C++ Code::Blocks
Setup time 0 minutes 2 minutes 15+ minutes 20+ minutes 20+ minutes
Platform Any (browser) Win / Mac / Linux Windows only Windows only Windows only
Compiler used Turbo C (real) Turbo C (emulated) Turbo C (native) GCC + WinBGIm GCC + WinBGIm
100% compatible Yes Yes Yes Partial Partial
Modern editor Yes Yes No Basic Basic
Works offline No No Yes Yes Yes
Cost Free Free Free Free Free

Which method should you use?

  • Just need to run a program quickly? Use the online compiler. Open it, paste your code, click run. Done.
  • Working on multiple programs regularly? Install the VS Code extension for the best editing experience with one-click compile.
  • Your college specifically requires Turbo C++? Use Method 3, but be prepared for the old-school editor experience.
  • Need a native Windows IDE without DOSBox? Try Dev-C++ or Code::Blocks with WinBGIm, but note that not all functions may behave identically to the original.

Test program

Use this simple program to verify your setup works, regardless of which method you chose:

#include <graphics.h>
#include <conio.h>

int main()
{
    int gd = DETECT, gm;
    initgraph(&gd, &gm, "");

    setcolor(YELLOW);
    circle(320, 240, 100);

    setcolor(GREEN);
    rectangle(220, 140, 420, 340);

    setcolor(WHITE);
    outtextxy(260, 230, "graphics.h works!");

    getch();
    closegraph();
    return 0;
}

Try it instantly: Open the graphics.h online compiler, paste this code, and click Compile & Run to see the output.