From installing IDE, graphics library, different functions with code and syntax , I am uploading in here.
1. Install Code::Blocks IDE from this link, which is easy to work with C/C++.
Computer Graphics(CG) is old library but basics of CG becomes clear using graphics.h library and its functions. (If above CodeBlocks version don't works for you or shows errors, try this 17.12 version
2. We need to download header files for graphics to work in our machine. Download 3 files from here.
Copy and Paste graphics.h and winbgim.h in the "include" folder inside MINGW folder of CodeBlocks folder in your machine. Generally the path is C:\Program Files (x86)\CodeBlocks\MinGW\include
4. Copy and Paste libbgi.a file in "lib" folder inside MINGW folder of CodeBlocks folder in your machine.
Generally the path is C:\Program Files (x86)\CodeBlocks\MinGW\lib
-
In the Code::Blocks IDE, open Settings-> Compiler in menu bar.
-
In the Popup Box appeared, click on Linker settings next to compiler settings.
-
Add the Path of libbgi.a in "Link libraries" by clicking on Add button and then Browse Icon. Address of the file might be like this C:\Program Files (x86)\CodeBlocks\MinGW\lib\libbgi.a
-
Then add (copy/paste) this below code in Other linker options, on right side of where you just added the path of libbgi.a file.
-lbgi -lgdi32 -lcomdlg32 -luuid -loleaut32 -lole32
-
Click on OK button to apply these changes and then close the application and then Restart your PC/Laptop.
6. Open Code::Blocks IDE after restarting is done and copy/paste this sample code to test the working.
Save file in C++ language with extension .cpp OR you can make project as console application in C++ and file is saved by default as main.cpp in codeblocks.
Output will be generated in the window of size 640x480
If you have some error in codeblocks 20 version, then follow this video. Maybe it will solve your issue.
Suggested by Meet