How to Set Up Dev Cpp for Graphics Program

 Hello,

In this blog, I am teaching you how to set up your Dev c++ IDE for graphics program.

For those who don't know dev cpp, It is a IDE(Integrated Development Environment) for building programs using c and c++ language. It is basically a text editor with inbuilt c compiler (MingGW) installed in it.

Ok, lets start our steps 

Step 1: Download Dev Cpp IDE

Firstly, lets download Dev Cpp IDE , You can download from this link .




or, In alternate you can google for download dev cpp , and you can get download link there.

Step 2: Install Dev Cpp in your windows 

After you downloaded the Dev Cpp IDE, you have to install the IDE on windows. It is clear forwarded step, 
  1. click on the file you downloaded 
  2. It might ask for administrator permission , allow it 
  3. it will ask you the folder where you want to install , you can select that else leave as default 
  4. once all done click on next and start 
  5. with in a minute , it will install the IDE in your windows 

Step 3: Download Graphics library 

You will need three files for setting up graphics in your Dev Cpp IDE . click me to download files
  1. graphics.h
  2. winbgim.h
  3. libbgi.a

Step 4: Set Up files in your IDE 

After you downloaded the files, extract that files and lets proceed the further steps.
  1. copy graphics.h and winbgim.h files from the folder 
  2. Navigate to the folder of Dev Cpp, if you havent selected the custom path for installation then it is probably this one, Cdrive > ProgramFiles(x86) > Dev Cpp


  3. Inside the folder of devcpp you can find the folder named MingGW64 , inside that you you will find a folder named include, paste those two files there.
  4. Copy the libbgi.a and navigate to the same MingGW64 and then open lib folder and paste it there 

Step 5: Open the Dev Cpp IDE 

After this, Open the Dev cpp IDE and then create a new file named test.cpp ,

write this code there,

#include<stdio.h>

#include<graphics.h>

int main(){

int gdriver = DETECT , gmode;

int x1 = 100 , y1= 200;

int x2 = 300 , y2 = 400;

initgraph(&gdriver , &gmode ,"Graph Console");

line(x1,y1,x2,y2);

getch();

closegraph();

return 0; 

save the file and then select the compiler from the right top, By defult it is set to 64 bit Release. Click on it and a dropdown will appear. click on 32 bit release 

further on, click on Tools > Compiler Options  and  firstly remove the defult linkers and add these linkers 

-static-libgcc -lbgi -lgdi32 -lcomdlg32 -luuid -loleaut32 -lole32 




click on okay and you are ready to go.

Step 6: Compile and Run your Program 

Now, you can can complile and run your graphics program here.



Remember these points for next time 

  • Always set the  compiler to 32 bit release for running the graphics program else i suggest for running other programs set it to 64 bit release 
  • Always save the file with .cpp extension as this graphics library does not work with .c extension 
  • Never save your file with the name graphics.cpp it might cause conflict between library and the file


Wishing you a Happy Programming!! Bye   😊😊

Post a Comment

0 Comments