How To Include Graphics H In Dev C%2b%2b

Posted on by

Compiling graphics codes on CodeBlocks IDE shows an error: “Cannot find graphics.h”. This is because graphics.h runs is not available in the library folder of CodeBlocks. To successfully compile graphics code on CodeBlocks, setup winBGIm library.

How to include graphics.h in CodeBlocks ?

Graphics in C language (graphics.h header file functions and examples) In this article, we will learn the use of ‘graphics.h’ in language C and will also make some programs based on our learning. I found a good library for the old-style bgi programming. Visit to Nurhidayat. I have used graphics.h in dev cpp. Though I can't remember the exact steps I used to include it, but I think the below answer is correct. Source: How to configure graphics.h in Dev-C > You can easily solve this problem, DEV-C do support gra. Apr 08, 2015 I have used graphics.h in dev cpp. Though I can't remember the exact steps I used to include it, but I think the below answer is correct. Source: How to configure graphics.h in Dev-C You can easily solve this problem, DEV-C do support gra.

The following files are needed with the C compiler to work in graphics: The Header File “graphics.h” that contains built-in graphic functions. This header file is included in the program. Borland Graphics Interface (BGI) files. These files contain graphics driver programs that initialize the computer monitor into graphics mode. Such an error is shown when the compiler can't find the file which your are trying to include. In all probability, you are trying out a program written for the Turbo.

Please follow below steps in sequence to include “graphics.h” in CodeBlocks to successfully compile graphics code on Codeblocks.
Step 1 : To setup “graphics.h” in CodeBlocks, first set up winBGIm graphics library. Download WinBGIm from http://winbgim.codecutter.org/ or use this link.

Step 2 : Extract the downloaded file. There will be three files:

  • graphics.h
  • winbgim.h
  • libbgi.a
  • Step 3 : 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.)


    Step 4 : Copy and paste libbgi.a to the lib folder of compiler directory.
    Front row mac download free.

    Step 5 : Open Code::Blocks. Go to Settings >> Compiler >> Linker settings.

    Step 6 : 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.

    Step 7 : In right part (ie. other linker options) paste commands

    -lbgi -lgdi32 -lcomdlg32 -luuid -loleaut32 -lole32

    Step 8 : Click Ok

    Step 9 : Try compiling a graphics.h program in C or C++, still there will be an error. To solve it, 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,

    Step 10 : Save the file. Done !

    Note : Now, you can compile any C or C++ program containing graphics.h header file. If you compile C codes, you’ll still get an error saying: “fatal error: sstream : no such file directory”.

    For this issue, change your file extension to .cpp if it is .c


    You may be wondering how to add graphics.h in dev C++. Dev C++ does not support BGI Graphics we have to include graphics library manually. Here are few steps you must follow before using graphics.h header file. .
    Download following files to the directories mentioned:
    graphics.h Directory:> C:Dev-Cppinclude
    libbgi.a Directory:> download to C:Dev-Cpplib)Include
    Creating Project:
    • STEP 1: Open DEV C++ Compiler
    • STEP 2: Creating New Project
    i. Go to File>New>Project as shown in following figure:
    ii. Create New Project 'DialogBox' will appear select 'empty project'
    and name your project in the space provided. Select Language
    C or C++ according to your need. Press Ok and select the
    location where you want to save.

    • STEP 4: Set linker parameters
    Navigate to 'Project' menu and choose 'Project Options'. A dialogbox
    will appear than select 'Parameters' option and type following in
    'Linker' field.
    -lbgi

    How To Include Graphics H In Dev C 2b 2b 1

    -lgdi32
    -lcomdlg32
    -luuid
    -loleaut32
    -lole32

    Press OK, you are now able to use graphics.h functions in your code.
    • STEP 5: Testing sample Program
    In new versions of dev c++ compiler automatically adds one source file to
    project. If there is no any existing source file simply add new file By
    chossing new file option from file menu. Type the following code and
    save the file. I saved file as 'main.cpp' its your chooice whatever you
    name it.

    How To Include Graphics H In Dev C 2b 2b 1b

    • STEP 6: Compiling and Runing the program
    If you have followed all the steps carefully after compiling and runing the
    program your output should be somthing like this:

    How to include graphics h in dev c 2b 2b 1b
    • STEP 7: Find more functions
    Follow these links for more functions of graphics.h
    1. http://www.programmingsimplified.com/c/graphics.h

    How To Include Graphics H In Dev C 2b 2b C

    2. http://www.cs.colorado.edu/~main/bgi/doc/initgraph.html

    How To Include Graphics H In Dev C 2b 2b 2c

    3. http://www.cs.colorado.edu/~main/bgi/doc/
    You can comment here if you have any trouble.