2

I have added winbgim.h and graphics.h to the include folder in the codeblock location. libbgi.a is also added to the lib folder.

Below code is to draw a cicle:

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

int main() {
    initwindow(300,300,"test");
    circle(100,100,100);
    getch();
    closegraph();
    return 0;
}

See the below picture, there is no circle drawn in the window:

image

What is the problem?

Spektre
  • 49,595
  • 11
  • 110
  • 380
miltonbhowmick
  • 324
  • 1
  • 5
  • 17
  • 3
    The fact that the only `return` in the code is `0`and the console says the process returned `-1073741819` leads me to believe that something went wrong during execution. Did you step through with a debugger? – Borgleader Jun 28 '18 at 19:30
  • @JesperJuhl It looks like Code::Blocks. – Ripi2 Jun 28 '18 at 19:36
  • I found [this BGI doc](https://www.cs.colorado.edu/~main/bgi/doc/initwindow.html) – Ripi2 Jun 28 '18 at 19:41
  • Try to add this line of code `int gd=DETECT,gm` – SSM Jun 28 '18 at 19:42
  • Also,remove `` from the code as it works in turbo c++ and likes only. – SSM Jun 28 '18 at 19:43
  • Do you use `-mwindows` flag for the compiler? Do you set "Console aplication" in C::B `Project->Properties`, `Build targets` tab, type ? – Ripi2 Jun 28 '18 at 19:45
  • @jesper its definitely codeblocks! Trubo c++ doesn't seem HD text on screen! – miltonbhowmick Jun 28 '18 at 19:46
  • @Ripi2 no, I didn't set these processes manually. Can you tell me the processes? – miltonbhowmick Jun 28 '18 at 19:49
  • Try setting "GUI application" instead of "Console application" in "Project" menu – Ripi2 Jun 28 '18 at 19:51
  • 1
    Error code `0xC00000005` is an Access Violation. – Remy Lebeau Jun 28 '18 at 20:33
  • In order to get WinBGI to work you have a few constraints. The libraries commonly available on the internet date back to 2005 and require GCC version 3.4. There are no assurances that it will work correctly with any of the 5 major GCC releases since, so make sure the GCC version you have is GCC 3.4 . Open a command prompt and type `g++ -v`. The version number should be at the bottom. Also note that 2005 was a Pre-Vista world and and Windows was a lot closer to the DOS roots that BGI was designed to support. Win BGI may not work under Windows 10 without a great deal of work. – user4581301 Jun 28 '18 at 21:59
  • Do you have to use BGI or can you use a graphics library that was developed for modern systems like the ones included in [SDL](https://www.libsdl.org) and [SFML](https://www.sfml-dev.org/)? These are significantly more relevant today than a graphics package designed back in the 1980s to support DOS 3 running on a 286 computer with a 16-colour EGA card. – user4581301 Jun 28 '18 at 22:06
  • @JesperJuhl conio.h still lived, at least as recently as MSVC 2015 and with greatly reduced functionality, in modern Windows. `getch` is still there, but I think it grew an underscore. – user4581301 Jun 28 '18 at 22:18

1 Answers1

1
  1. Try these files: https://github.com/SagarGaniga/Graphics-Library

  2. set your environment variable and check it (by typing gcc --version on cmd). For setting an environment variable:https://www.youtube.com/watch?v=GWJqsmitR2I (time snap : 4:32 to 5:47)

  3. still not working try to install the latest version of code blocks and perform steps 1 and 2 again.

Dharman
  • 30,962
  • 25
  • 85
  • 135