Installing Borland Turbo C DOS Graphics Emulation (graphics.h) under Code::Blocks

(for using graphics.h under DEV-C++ see

 Michael Main has implemented a BGI empulation graphics library for Windows applications (based on the Borland Turbo C++ DOS graphics library) to be used under MinGW (and therefore Dev-C++ and Code::Blocks) .


Download:  The required files are:

graphics.h  (download to C:\CodeBlocks\MinGW\include)
libbgi.a (download to C:\CodeBlocks\MinGW\lib)


Link to graphics library: After opening a  Code::Blocks console project which uses graphics.h you need to set up the libraries for the linker.

In  Project > Build Options > Linker Settings > Other Linker options add the following


Operation: You can now use <graphics.h>, e.g. try this simple program (from

  #include <graphics.h>
  int main() 
      initwindow(400,300); //open a 400x300 graphics window
      while(!kbhit());     //wait for user to press a key
      closegraph();        //close graphics window
      return 0; 

i.e. create a new Code::Blocks console application project, paste the above code into the main.cpp file, set up the link to the graphics library (described above), compile and run.