Code::Blocks is mostly used opensource IDE due its great features. However it doesn’t support graphics, but we can make it work by adding WinBGIm manually. Code::Blocks is lightweight and easy to use, it loads source code much more faster than that of Eclipse. Becoming opensource it is also available for Linux and is free to download and use. It is best IDE for beginners, who wants to learn FORTRAN, C and C++ and for creating small projects. With addition of WinBGIm in Code::Blocks we can use graphics.h header file and compile and run graphics program in C and C++. However for large projects Code::Blocks may not be good.
How to add graphics.h in Code::Blocks?
- Download WinBGIm. CLICK TO DOWNLOAD. Downloading from other website may not work.
- Extract it.
- Open info.txt for linker options and more information.
- Copy MinGW folder to your Code::Blocks installation directory. Default Code::Blocks installation directory is C:\Program Files (x86)\CodeBlocks. There will be MinGW folder already. Copying new MinGW folder only adds some library (libbgi.a) and header (winbgim.h, graphics.h) files in that directory. To manually add files, copy graphics.h and winbgim.h files in include folder of your compiler directory which is C:\Program Files (x86)\CodeBlocks\MInGW. And copy libbgi.a to lib folder of your compiler directory.
- Open Code::Blocks. In open Settings >> Compiler >>Linker Settings. Click Add button in link libraries part and browse and select libbgi.a file you just copied to MinGW folder.
- In right part (i.e. other linker options) paste commands –lbgi -lgdi32 -lcomdlg32 -luuid -loleaut32 -lole32
- Click OK.
You can also watch my short video:
Now you can run graphics program in Code::Blocks. I have added a sample program clock.cpp with that WinBGIm, you can try compiling it.
You may also like How To Install Dark Themes In CodeBlocks?