How to use graphics.h library in C++ Code Block

Hi there, today’s blog will show you, how to use libraries in codeBlocks blissfully

So, to clarify, I will demonstrate  one example for you

At this instant, we will use a library called graphics.h

  1. Extract the files from .zip file
  2. Go to windows c drive –>program files(x86)–>codeblocks–>mingw–> include
    • C:\Program Files (x86)\CodeBlocks\MinGW\include
  3. At this instant copy both header files of library(graphics, winbgim) and paste it in “include folder”
  4. Press back button you will find “lib folder”
  5. Open “lib folder” copy the third file of library(libbgi.a) and paste it in “lib folder”
    • C:\Program Files (x86)\CodeBlocks\MinGW\lib
  6. Open codeblock ide–>click settings–>compiler–>linker settings–>Add –>to select the path again go to “lib folder”  and select file (libbgia) –> ok
  7. Paste this code on other linker option’s –>-lbgi -lgdi32 -lcomdlg32 -luuid -loleaut32 -lole32
  • Run a simple program to test whether graphics.h library is working or not
//#include <iostream>
#include<graphics.h>
using namespace std;
int main()
{
    initwindow(1000,600);
    line(200,210,700,410);
    getch();
    return 0;
}
  • Output

Mohammed Anees

Hey there, welcome to aneescraftsmanship I am Mohammed Anees an independent developer/blogger. I like to share and discuss the craft with others plus the things which I have learned because I believe that through discussion and sharing a new world opens up

Leave a Reply

Your email address will not be published.