How to enable graphics.h in CodeBlocks

By default graphics.h library doesn’t include in CodeBlocks software. You can run graphics program by setup your CodeBlocks software like as below.

Step 1: At first download this. Click Here

Step 2: Now extract the downloaded zip file and copy the graphics.h and winbgim.h files and paste these files into your CodeBlocks compiler’s include folder. Copy the libbgi.a file and paste it into the lib folder.

include folder pathC:\Program Files\CodeBlocks\MinGW\include

lib folder pathC:\Program Files\CodeBlocks\MinGW\lib

Step 3: Now open the CodeBlocks software and go to the settings menu to compiler and select Linker setting. Add libbgi.a file by clicking add button and paste the code in the sidebox (Other linker options)

-lbgi -lgdi32 -lcomdlg32 -luuid -loleaut32 -lole32

Linker setup for graphics.h

Step 4: Now save the settings by clicking ok button. Restart CodeBlocks software and run your program.


1. Your program should be c++ (.cpp) extension

2. If you get any error please replace the code of line no 302 in graphics.h file with

int left=0, int top=0, int right=INT_MAX, int bottom=INT_MAX,

Tags : , , , , , , , ,

Share on :

3 Responses to “How to enable graphics.h in CodeBlocks”

  1. leo minhaz says:

    thank u so so much. it eventually helped me a lot to enable graphics in my codeblocks.

  2. Md.Abdullah says:

    This is most important solution for computer programming language Turbo C++ Alter net use.Because turbo c++ is very difficult for codding .
    On the other hand using code block most sufficient and smoothly use
    for codding.I am very glad to Mr. Harun post this most necessary codding platefrom.

  3. Asad says:

    Thanks thanks thanks….it works 100% ..agin thank-you

Leave a Reply to Md.Abdullah

1 + nine =