0

Please Click Here To Check The Problem ScreenShot

The above image contains --- Error My Code On Graphics Inshort All You Need To "Diagnosis"

Please help I am trying to create a tictactoe game there but unfortunately its giving the error in beginning only..

Please NOTE- *>The same code is running well in Turbo c++ . *>I have fixed the inclusion of the entire package of "winbgim" step by step. *>My OS-Windows 10

#include <graphics.h>
#include <conio.h>
int main()
{
  int gd=DETECT;
  int gm;
  initgraph(&gd , &gm ,"C:\\TC\\BGI");

  getch();
  closegraph();
  return 0;
}
genpfault
  • 51,148
  • 11
  • 85
  • 139
Bangali
  • 9
  • 1
  • 2
  • I am new to stackoverflow and this is my firstquestion asked here. – Bangali Jul 07 '16 at 09:10
  • Please set a breakpoint at the first line in main (int gd=DETECT) and step through in order to see where your program actually crashes. Are you familiar to debugging? You really should, because its a valuable tool to find and fix errors in your code. – Erik Jul 07 '16 at 09:32
  • Erik, I have tested step by step and this problem is being generated as I compile after the initgraph() is being added in the code.Before the adding it runs perfectly... – Bangali Jul 07 '16 at 13:49
  • Maybe it's a duplicate of http://stackoverflow.com/questions/25563396/codeblocks-error-in-graphics-library – Erik Jul 08 '16 at 04:03

1 Answers1

0

You need to do two things: First- declare your path as char* otherwise you will get an error of "deprecated conversion from string const to char*" Use this one:

 char driver[]="C:\\TC\\BGI";

Second- Delete that libbgi file which you previously downloaded to use graphics.h in codeblocks and download a new one using the link below:

https://github.com/stahta01/windows-games/blob/master/WinBGIm/lib/libbgi.a

Then follow the same steps as you must have done earlier: 1. Go to the settings in codeblocks 2. Choose compiler option and then linker settings 3. Add the new libbgi library using ADD option and write this in the right hand side column:

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

Now smile! Everything is set and start coding! :) Hope it works for you !

wait
  • 11
  • 3