Codeblocks isn't showing graphics window

-1

I have tried to learn about graphics using codeblocks , and have initialized the graphics header to my library , every graphics code builds and compiles , and shows :

Process returned -1073741819 (0xC0000005)   execution time : 2.776 s
Press any key to continue.

but it doesn't show the graphic window. For example I have written a code to show lines, it doesn't show anything.

I tried this code at first, and it showed:

F:\Code blocks\Lab final\Graph.cpp|12|warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]|

Here is the code:

#include<graphics.h>
#include<stdio.h>
#include<conio.h>
int  main() {
    int gdriver = DETECT, gmode;
    int x1 = 200, y1 = 200;
    int x2 = 300, y2 = 300;
    char driver[] =  "";
    initgraph(&gdriver, &gmode,driver);
    line(x1, y1, x2, y2);
    getch();
    closegraph();
}

I expected to see the graphics window , but it doesn't show anything .

c++
winbgi
asked on Stack Overflow Aug 10, 2019 by Israq Ahmed Anik • edited Aug 11, 2019 by Spektre

2 Answers

-1
  • if you have tried a lot and not getting how to completely setup graphics in code block then you are at right place.

1).First delete your codeblock

2).Then install mingw-get-setup (32 bit) and setup it using any youtube video. If you have already installed it than it's fine. You can skip this step.

You can Use following link to download mingw(avoid if you already have it).

Mingw-get-setup Download

3).Now install 32 bit version of codeblocks with mingw setup

Download CodeBlocks 32 bit with mingw

  • Now If you are Have Installed Ming-W in you C drive check that Your code block is by default taking compiler path as this c drive's MingW's path otherwise do reset default setting in codeblocks ->settings-compiler-toolchain executable

Image

  • Then Go In the incude section of that C drive Mingw's include section rather than going in codeblocks mingw's include section now paste following files

    Note:- If You Have Already copied graphics.h and winbgim.h files from other sources Then Also Replace It With Following

Note:- Best way to find include section is go in C drive-Mingw and type iostream in search bar of your file explorer and right click on iostream file and open its location and to find correct lib go back from this include section and click on lib section NOTE:-Location of lib may differ but correct lib is lib section with lot .a files

1 Link Of Graphics.h File From Israq ahemad drive

2 Link Of Winbgi.h File From Israq ahemad drive

  • Now Go In that C drive Mingw's Lib section rather than going in codeblock's mingw's lib section and paste following file in that.

3Link Of libbgi.a File From Israq ahemad drive

  • Now Go to setting-compiler-linkersetting and in linkersetting add libbgi.a file location which you have just pasted and in right side box paste -lbgi -lgdi32 -lcomdlg32 -luuid -loleaut32 -lole32

Image that Shows Where To Add libbgi.a path.

  • And Now Just Try To Write
#include<graphics.h>
#include<stdio.h>
#include<conio.h>

int main()
{
    int gd,gm;
    detectgraph(&gd,&gm);
    initgraph(&gd,&gm," ");
    circle(200,200,100);
    getch();
    closegraph();
    return 0;
}

in file with cpp extention.

And you will get following output

Image that Shows Desired Outputs

answered on Stack Overflow Mar 4, 2021 by Aman Shaikh • edited Mar 27, 2021 by Aman Shaikh
-2

After trying a lot of sites I have found one from where downloading the files that can solve that issue , and for anyone that are facing the same problem , you can download the files from here and follow the steps from the read me file , and it will be solved .

And thanks to everyone who tried to help and replied to my question .

answered on Stack Overflow Aug 10, 2019 by Israq Ahmed Anik

User contributions licensed under CC BY-SA 3.0