-2

I had setup codeblocks for graphics programming. like I install winbgim file. and done other setup in the codeblocks linker setting. but when I ran a program like this

#include<graphics.h>
#include<stdio.h>
#include<conio.h>

 main(void) {
    int gdriver = DETECT, gmode;
    int x1 = 200, y1 = 200;
    int x2 = 300, y2 = 300;
    system("cls");

    initgraph(&gdriver, &gmode, "");
    line(x1, y1, x2, y2);
    getch();
    closegraph();
}

it did not run as I expected .the process returned by 0xc0000005 . and also the winbgi window did not opened. so plz help me to out of this problem

genpfault
  • 51,148
  • 11
  • 85
  • 139
Tushar Mia
  • 375
  • 2
  • 9

2 Answers2

1

I faced the same issue. Did you download WinBGIm library from its website?

If yes, then the header files graphics.h and winbgim.h have a bug. On line 302, of each of those files, replace right = 0 with top = 0.

But, then the problem is the library itself was built using the "buggy" header files, so:

  • you either need to build the library from the source code yourself, or
  • you need to download corrected library which was already built by someone else who faced this issue. Fortunately, I found such a library here (Link in Step 2).

So, now if you put the corrected files (header files as well as the library), in the target folders and re-build, the program should not crash.

kiner_shah
  • 3,939
  • 7
  • 23
  • 37
-3

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. 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.

S.S. Anne
  • 15,171
  • 8
  • 38
  • 76
Roxy Hasan
  • 11
  • 3
  • try to format and structure your post. Right now it's a wall of text and it's unreadable – bolov Apr 22 '19 at 05:14