Sunday, 6 September 2015

Running Graphics Program of C on Windows 7 64 bits In CodeBlocks IDE 13.12

Today we are going to see how to run C graphics program on 64 bits Windows 7 using CodeBlocks 13.12. 

It will require only 12 steps. Follow with caution and you are done.

These are the instructions I have tried for 64 bits windows 7:
  1. Download zip file from this repository:
    This one is having latest files of Graphics Libraries.

  2. Now either you are using external GCC compiler or internal GCC compiler doesn’t matter, just follow the universal procedure recommended for this.
  3. Copy the following files 
To (MinGW)
include folder  => graphics.h
src folder => Winbgim.h
lib folder => libbgi.a

           If any of the files are already at destination, please overwrite as these are going to work for 64
           bits versions.

4.  Now, go to Setting => Compile and Debugger => Selected Compiler => GNU GCC Compiler.
           -  I will recommend to make copy of existing compiler and rename it. So that any kind of mess will not
           disturb other type of program execution. 

     5.    Now in Linker settings => Add => File => C:\MinGW32\lib\libbgi.a
     6.    Go to right part, other settings paste these parameters:
           -lbgi -lgdi32 -lcomdlg32 -luuid -loleaut32 -lole32
     7. Now half of the configuration has been done.

     8. Create simple empty project using codeblocks and add file with extension .cpp.
     9.     Most IMPORTANT part is now:

Now, right click on Project Name => Build Options => selected Compiler.

       You have to select the compiler which you have configured.
       Otherwise you will get:
       i. Memory access violation error "Process-returned-1073741819-0xc0000005" 
      ii. Segmentation fault.
     After successfully completing above steps, try the following program with Hello.cpp   
     This is my sample program to print name of screen:

   int gd = DETECT,gm,left=100,top=100,right=200,bottom=200,x= 300,y=150,radius=50;  
   initgraph(&gd, &gm, "C:\\TC\\BGI");  
   rectangle(left, top, right, bottom);  
   circle(x, y, radius);  
   bar(left + 300, top, right + 300, bottom);  
   line(left - 10, top + 150, left + 410, top + 150);  
   ellipse(x, y + 200, 0, 360, 100, 50);  
   outtextxy(left + 100, top + 325, "My First C Graphics Program");  
   return 0;  

    10.  Now, rebuild the project.

    11.  After that, compile and run.

    12.  You will definitely see such message printed,


  1. Howdy --
    I'm attempting to find libbgi.a in your windows-games, and don't see it. Could you point me towards this?
    Many thanks,
    David Small

    1. Download this file it is having libbgi.a

  2. This comment has been removed by the author.

  3. This comment has been removed by the author.

  4. i followed your steps carefully, but when i run the program, it stops working.. A pop up window by Windows OS comes and "says "myprogram.exe" has stopped working. Windows is finding a solution for this"....