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
Step 2: Install Dev Cpp in your windows
- click on the file you downloaded
- It might ask for administrator permission , allow it
- it will ask you the folder where you want to install , you can select that else leave as default
- once all done click on next and start
- with in a minute , it will install the IDE in your windows
Step 3: Download Graphics library
- graphics.h
- winbgim.h
- libbgi.a
Step 4: Set Up files in your IDE
- copy graphics.h and winbgim.h files from the folder
- 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
- 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.
- 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;
}
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
0 Comments