- CodeBlocks IDE. You can download it here.
- graphics.h header file should be included in CodeBlocks. (Dont't worry. The steps to do so are given below.)
- First setup WinBGIm library. Download WinBGIm from (http://winbgim.codecutter.org/).
- Extract the downloaded file. There will be three files:
- graphics.h
- winbgim.h
- libbgi.a
-
Copy and paste graphics.h and winbgim.h files into the include folder of compiler directory. (If you have Code::Blocks installed in C drive of your computer, go through: Disk C >> Program Files >> CodeBlocks >> MinGW >> include. Paste these two files there.)
-
Copy and paste libbgi.a to the lib folder (inside MinGW folder) of compiler directory.
-
Open CodeBlocks. Go to Settings >> Compiler >> Linker settings.
-
In that window, click the Add button under the “Link libraries” part, and browse. Select the libbgi.a file copied to the lib folder in step 4.
-
In right part (ie. other linker options) paste the following commands:
-lbgi -lgdi32 -lcomdlg32 -luuid -loleaut32 -lole32
-
Click OK.
-
Open graphics.h file (pasted in include folder in step 3) with Notepad++. Go to line number 302, and replace that line with this line : int left=0, int top=0, int right=INT_MAX, int bottom=INT_MAX,
-
Save the file. Done!
Try running this demo code to see if it is working.
#include<graphics.h>
int main()
{
initwindow(500, 500);
outtext("This is working!");
getch();
return 0;
}