How to Include graphics.h in Code::Blocks?

| |

Most of us learning Computer graphics want to get rid of weird looking and boring Turbo. ” Turbo C++ is a discontinued C++ compiler and integrated development environment originally from Borland. “, it is the first line about Turbo C++ in Wikipedia. Code::Blocks can be a better alternative to Turbo C++ for Computer graphics codes in C++.

According to Wikipedia,

Code::Blocks is a free, open-source cross-platform IDE that supports multiple compilers including GCC, Clang and Visual C++. It is developed in C++ using wxWidgets as the GUI toolkit. Using a plugin architecture, its capabilities and features are defined by the provided plugins.

So how to compile graphics code in Codeblocks? It usually shows an error, “Cannot find graphics.h”. This error message is because you don’t have graphics.h header in the library folder of Code::Blocks. BGI(Borland Graphics Interface) is a graphics library for rendering in the DOS platform. So with Windows we have WinBgi which is a Borland emulation for MingW.

How to Include graphics.h in Code::Blocks?

Before proceeding, you need to download the libraries from the link below: Download Here

If the above button doesn’t work, copy and paste the below link in the browser.

https://drive.google.com/open?id=1N9AT5pMYT9s-rzo8fN1tKI0ufB7KkeYa

(You can also find the library in official website but installing those files will end up with some errors so we have provided Google drive link of error free library files)

Step 1: Extract the files from the Zip that you downloaded from google drive. There are 3 files: 

  • graphics.h
  • winbgim.h
  • libbgi.a

Step 2: Copy and paste libbgi.a file to ”lib” folder inside the compiler directory.

(Find your Codeblocks installation directory first, there is MinGW folder inside which the lib folder lies. Mine is C:\Program Files (x86)\CodeBlocks\MinGW\lib )

Step 3: Copy other two files graphics.h and winbgim.h to “include ” folder inside the compiler directory.

Step 4: Open CodeBlocks and Go to Setting>>Compiler

Step 5: Click Linker Settings and click on ‘Add’ button below link libraries box .  

  Select libbgi.a file added in Step 2 (C:\Program Files (x86)\CodeBlocks\MinGW\lib\libbgi.a) and click ok.  

Step 6: Now paste the following commands in the right side box(Other linker options:) -lbgi -lgdi32 -lcomdlg32 -luuid -loleaut32 -lole32

Click Ok button in  right bottom corner.   Great!! Now you are ready to run your graphics code using graphics.h library in CodeBlocks.
Did it work?? Feel free to comment below. ????

Previous

Flutter 1.17: first stable version for 2020 released along with Dart 2.8

Steve Jobs: a Self-made billionaire

Next
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x