Search code examples
c++codeblocksbgi

Windows error while writing graphic codes in Code Blocks. How to fix it?


I am having trouble using graphics.h in code blocks.

I have installed winbgi. Edited 302nd line. Linked lib file and all that stuff is done. So, I don't have any error regarding graphics header file.

But whenever I run/build any code involving graphics functions, windows gives an error ".. has stopped working". How to fix this?

I am using Codeblock v16. Windows 7ultimate - 64bit.

Here is my code:

#include<graphics.h>
int main() {
   int gd = DETECT,gm;

   initgraph(&gd, &gm, "c:\\tc\\bgi");

   line(80, 100, 100, 100);
   getch();
   //return 0;
}

screenshots:

screenshot of codeblock window

Screenshot of Error window


Solution

  • [SOLVED]

    Unfortunately, it was all about 'bad' library files. I think, many have downloaded same(with bug) files in internet. Now I have bug-free files shared in google drive. And also Code::Blocks 16.01 (latest version)

    Here's link. Replace old files with these new ones.

    I have explained those steps and few FAQs here on this topic with links and test codes.