0

I have a program in c++ that uses graphic.h I want to open it with dos-box but when I try I get this error from dos-box:

BGI Error: Graphics not initialized (use 'initgraph')   

I have used initgraph in my program in this way:

gd=DETECT;
initgraph(&gd,&gm,"");
genpfault
  • 51,148
  • 11
  • 85
  • 139
Feri
  • 1,071
  • 7
  • 19
  • 1
    You may be using it wrong. Check this page: http://www.cs.colorado.edu/~main/bgi/doc/ – Gorpik Jul 31 '13 at 12:14
  • 1
    Show us your code. At the least a relevant portion of it. Then we might be able to help. – Bart Jul 31 '13 at 12:15
  • gd=DETECT initgraph(&gd,&gm,"") the program used to run correctly with this codes in windows 7 and dos-box – Feri Jul 31 '13 at 12:17
  • More details are needed. It seems this is Borland specific. Some code would also be useful to determine what happens. – Shlublu Jul 31 '13 at 12:17
  • 3
    Wrong path to BGI probably in the code. That said, don't use Turbo and their outdated compilers and libraries. – DUman Jul 31 '13 at 12:17

2 Answers2

0

Check the initgraph(), it should be something like

initgraph(&gd,&gm,"C:\TC\BGI");

If it doesnot work try giving an extra slash like:

initgraph(&gd,&gm,"C:\\TC\\BGI");

If again it doesnot not work check the environmental variables also.

You may refer to existing post in BGI error, How to Resolve it?

Community
  • 1
  • 1
Saby
  • 718
  • 9
  • 29
  • 1
    and those backslashes should most probably be escaped. – Bart Jul 31 '13 at 12:21
  • I can't find the file BGI in the folder that contains tc.exe – Feri Jul 31 '13 at 12:23
  • @Feri: That is the main problem, you will find the drivers in BGI folder, please make the config correct – Saby Jul 31 '13 at 12:26
  • I think they are in the folder that i have turbo c. – Feri Jul 31 '13 at 12:28
  • @Feri: Can you pls give more details? Here the initgraph is defined in the the BGIfolder only and you can also trying copying the \tc\bgi\EGAVGA.BGI file to your local folder where you are running the application – Saby Jul 31 '13 at 12:31
  • There is not a BGI folder but i have .bgi files in the local folder and i use "" as the third parameter for initgraph – Feri Jul 31 '13 at 12:34
  • @Feri: Can you try copying the \tc\bgi\EGAVGA.BGI file to your local folder wfrom here you are running the application – Saby Jul 31 '13 at 12:36
  • As I said I have this file in the folder i run the application – Feri Jul 31 '13 at 12:38
0

I was able to run my old college graphics project in Turbo C++.

int gd=DETECT,gm;

 initgraph(&gd,&gm,"C:\\TURBOC3\\BGI");

 if(graphresult()!=grOk)
 {
  closegraph();
  cout<<"Error Initializing graphics engine!!"<<endl;
  getch();
  return -1;
 }

I used Macbook Pro early 2015 model with Dosbox installed alongwith Dapplegrey. http://www.classics-for-x.info/csx/dapplegrey/index.htm

Screenshots: [1]: https://i.stack.imgur.com/Dv0ON.jpg [2]: https://i.stack.imgur.com/deQiG.jpg