I've tried out suggestions from several posts related to BGI Error (on daniweb n innumerable sites)but it just doesnt get solved.. Whenever i try to execute (after compiling successfully) a graphics program it either exits out of C and into DOS mode or it gives an error "The NTVDM comp encountered an illegal instruction #########(sum hexadecimal code) and i get options Close and Ignore(although after this i hav to restart TC)..

Let me give my computer specifications: 3.12GB RAM, Nvidia GeForce 7050/Nvidia nForce 610i 512 MB graphic card, win XP pro service pack 2, Intel Core2Duo Processor(2.20GHz) n a 19"W Acer LCD screen.. (tell me if u need ne more specifications).... Even a simple program lyk the 1 below is not working.....

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

void main()
{
int gd,gm;
gd=DETECT;
detectgraph(&gd,&gm);
initgraph(&gd,&gm,"C:\\TC\\BGI");

line(100,100,200,100);

getch();
closegraph();
}

Suggestions tried out by me
------------------------------------
1. I've already checked the [X] Graphics library option in Options->Linker->Libraries

2.I checked my BGI folder.. it has all the reqd BGI files such as EGAVGA.BGI, CGA.BGI n more


3.I've downloaded n tried atleast 5 TC's(v. 3.0) frm different sources.. none of em support graphics.. so there must be sumthin wrong wid my comp.. A program which works perfectly well in college doesnt work on my brand new home comp!!


4.I've even tried out running TC in compatibility mode for Win 98,95 but to no avail

I hope sum1 can tell me a permanent solution for this problem

P.S. All other types of programs work in my TC.. Only programs involving graphics do not work at all!!

Well I found this thing in your code:

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

Its normally this way:

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

When you are so sure about the libraries you possess then try out the example program given for <graphics.h> that should work fine for a try(As you are using TC).

If not follow this path:
start->control panel->system->advanced->Environmental Variables->System variables->find PATH->Click Edit->

After this DO NOT change anything else just include ; and then your TC path at the end.

Note: To find a solution to your problem you gave us all the details. Only your compiler configuration would be enough and the platform you are running it on.(Graphic details at max).Your other PC details wont be necessary. ;)

> Let me give my computer specifications: 3.12GB RAM, Nvidia GeForce 7050/Nvidia nForce 610i 512 MB graphic card,
> win XP pro service pack 2, Intel Core2Duo Processor(2.20GHz)
Now let me give you the spec of your machine, which that fossil compiler deals with.
Then you decide whether you spend too much money on a Ferrari, only to rip the engine out and drive it round like a horse and cart.

> 3.12GB RAM
Nope, 640K (a stunning 0.02% of the total available).
Worse than that, it's all chopped up into not-so-handy 64K blocks with the out-moded segmented architecture.

> Nvidia GeForce 7050/Nvidia nForce 610i 512 MB graphic card
256K graphics card, no video acceleration, 256 colours max, 640x480 resolution max.

> win XP pro service pack 2
DOS (well, a bad emulation of DOS anyway).

> Intel Core2Duo Processor(2.20GHz)
Single core, using only 8086 instructions in 16-bit mode.

Here, have an abacus.

Yes.. i tried even that C:\TC\BGI n i STILL get the same problem.. here's the actual image of the problem that i'm facing.. when I press Ctrl+F9(for graphics programs), the screen goes blank for a sec n then i come back 2 windows with this pretty msg at the center of the screen!!:icon_frown:


>The purpose behing me giving all the specifications of my comp was (not 2 blow my own trumpet) 2 clear a few misunderstandings.. one of our profs who teaches at Master's level told us that graphics doesn't work on 19" LCD monitors(can u believe that??!

>Csurfer, I've also tried out setting system variables as you said.. there were 2 system variables with names path (not PATH unless ur suggestion wasn't case-sensitive) and PATHEXT.. i tried indepepndently with each of them.. i wrote ;C\TC\TC.EXE(tell me if nething's wrong with it) but to no avail

>Moreover I saw another post on Daniweb in which the victim faced the same problem as i do now n he was advised 2 use a different compiler.. Now although this is a good suggestion..i would appreciate it if sum1 culd actually take the pains 2 explain(and if possible solve that problem) me why even a simple graphics program doesn't work on my home comp but executes without any problem whatsoever on my college comp(i even copied that TC n pasted that in my comp only to end up with same problem!)

Attachments 16_bit_msdos_subsystem.jpg 15.44 KB

Like I said, bad emulation of DOS.

> one of our profs who teaches at Master's level told us that graphics doesn't work on 19" LCD monitors
Find another college, the one you're at has no useful information to teach. Ask him how the hell windows manages to draw on the monitor then.

> The purpose behing me giving all the specifications of my comp was (not 2 blow my own trumpet) 2 clear a few misunderstandings
I couldn't care less about your machine spec.
I was only pointing out that you're NOT making the best use of it.
If you're going to use a 30 year old compiler, then expect problems. It's a problem which is only going to get worse in coming years.

Unless you're planning to be a museum curator, knowing ANYTHING about TC is a waste of effort.

Whilst I could help, I choose not to. In the hope that you'll give up the fossil hunt and just get a modern compiler which actually matches your OS and join the rest of us in the 21st century.
You might figure out what "no longer supported" actually means then.

ya even i hav a same problem with my friends pc his configration is also very similar i.e.
2GB RAM,Nvidia mobo,Nvidia 512 MB graphic card, win XP pro service pack 2, Intel Core2Duo Processor(2.56GHz) n a 19"W LG LCD screen

n every one gives dose solutions u mentioned,which r of no help tried long bak

he wants it to work desparately @ ne cost
is d 19" lcd really d problem ????

It seems you read all the posts about the problem, but none about the solutions. Computer specs are not the issue. Care to post which compiler you use?

>Csurfer, I've also tried out setting system variables as you said.. there were 2 system variables with names path (not PATH unless ur suggestion wasn't case-sensitive) and PATHEXT.. i tried indepepndently with each of them.. i wrote ;C\TC\TC.EXE(tell me if nething's wrong with it) but to no avail

Hey its just the path variable ( Path ) ok and whenever you are setting a path you don't include exe files to it . You just need to include C:\TC\BIN;C:\TC\LIB;C:\TC\BGI or in total as C:\TC ok .
The syntax of the path is also wrong and also the object you choose to include in the path.

Csurfer
Thank you for correcting that Path mistake...


  1. Hey its just the path variable ( Path ) ok and whenever you are setting a path you don't include exe files to it . You just need to include C:\TC\BIN;C:\TC\LIB;C:\TC\BGI or in total as C:\TC ok .
    The syntax of the path is also wrong and also the object you choose to include in the path.

    I've included Path exactly as per your instructions but the same problem arises as mentioned in my first post.

  2. I've also tried changing screen res for the VDU to 800 X 600 in addition to trying out 16 bit n 8 bit color quality. Also i tried running TC.EXE using compatibility settings for 256 colours without an ounce of success
  3. Well I found this thing in your code:

    Help with Code Tags c Syntax (Toggle Plain Text)

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

    Its normally this way:

    Help with Code Tags c Syntax (Toggle Plain Text)

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

    Mr. Salem has clearly mentioned that its always C:\\TC\\BGI(or whatevr path EGAVGA.bgi is in) in the following thread
    http://www.daniweb.com/forums/thread76092.html

bugmenot
>he wants it to work desparately @ ne cost
is d 19" lcd really d problem ????

19" LCD shud not b a problem..Read Mr. Salem's 2nd post in the same thread.. Also because it works perfectly fine on my friends' 19" LCD VDUs(luk at the irony:many of them are least interested in TC unlike me n yet it works perfectly fine there!!)


death_oclock
My compiler is Turbo C++ 3.0 Borland International (if this is not the answer that you were expecting kindly let me know that)

>It seems you read all the posts about the problem, but none about the solutions.
Most of the people on the net hav done silly errors like

C:\TC\BGI //instead of 
C:\\TC\\BGI

A few of the many pages i visited apart from DaniWeb forums are:
http://www.programmersheaven.com/mb/CandCPP/352840/352846/re-bgi-error-graphics-not-initialized-use-initgraph/?S=B20000&ReadPostMode=1
http://www.thinkdigit.com/forum/archive/index.php/t-50748.html
http://www.codeguru.com/forum/archive/index.php/t-408756.html
Now, i am not implying that i've not done a silly error.. just that my error and its corresponding SOLUTION is not one of those on the net..
Moreover i can't even view what my graphics error is from the following piece of code which i embed in my simple programs

errorcode = graphresult();

if (errorcode != grOk) /* an error occurred */
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1); /* return with error code */
}

BECAUSE the screen goes blank n i get the msg "THE NTVDM CPU ENCOUNTERED AN ILLEGAL INSTRUCTION"(which i've already mentioned in this thread b4):

yeah, I got the same situation.
I changed the path to C:\\TC\\BGI then an error message appear like this:
"16 bit MS-Dos sybsystem
Turbo C++IDE
The NTVDM CPU has encountered an illegal instruction.
CS:0000 IP:00 blah blah"
then I look down to my taskbar, I could saw my program for a moment then it gone.
Could some 1 plz help plz

yeah, I got the same situation.
I changed the path to C:\\TC\\BGI then an error message appear like this:
"16 bit MS-Dos sybsystem
Turbo C++IDE
The NTVDM CPU has encountered an illegal instruction.
CS:0000 IP:00 blah blah"
then I look down to my taskbar, I could saw my program for a moment then it gone.
Could some 1 plz help plz

Maybe print the error message (see grapherrormsg(...)) to a file to get a clue about what's wrong.

error code was -3, grFileNotFound, dun know wat to do now, plz help, I have downloaded turbo C++3.0 about 10 times, and still got the same problem

I have a machine with similar configuration. I have tried all suggestions posted above but not successful. I think the problem is of LCD monitor.

Thanks

Hey frnds i have the same problem..
its only for the nvidea graphics card
the new nvidea graphics card does not support the 16 bit graphic and the BGI is also 16 bit graphics.
now the solution:
when i removed the graphics card the program run easily.. but without removing the graphics card i cant found any solution till now.
so try to remove ur graphics card.. i am 100% sure the programs will run.
bye. thank u.

It's NOT a problem with LCD monitors. I use turbo C 1.01 all the time, and have an LCD monitor (Samsung), and it's fine. The OUTPUT is the same, an LCD monitor just uses it for a different device, downstream.

It's also NOT a NVidia card compatibility problem. I have one of those also - no problem. They are backward compatible with the old VGA standard that Turbo C supports.

There are two steps to making this work - but the first one should already be done for you, but check it anyway:

1) Click on the Options --> Linker in the TC IDE (where you might see your code) You should have some items in there that are checked with an [ X ]. Be sure NOT to mess with other settings, but see that Default Library and Graphics Library are [ X }'d.

2) Move these two files, into your C:\TC\BIN directory:
EGAVGA.BGI
EGAVGA.OBJ

The EGAVGA.BGI file is required. The EGAVGA.OBJ file just helps speed things along

These two files are in the default directory: C:\TC\BGI

Now run this Borland Turbo C example program, and see if it works for you. It simply draws a white diagonal line, on a black graphics screen.

Note especially the code it uses! Put that code into your graphics program, instead of the current "C:\\TC\\BGI" directory that you're using now.

Salem is really a fine programmer, but refers to Turbo C as "archaic crap". You can take his advice if you want. I just use it, nearly every day. (Turbo C/C++, ver. 1.01)

The only problem I've found (minor), is that when I leave a graphics program, the TC IDE will have a slight color error that makes it look "washed out". If it bothers you, close Turbo C, and restart it. The colors will now be right again.

This is the example program from Turbo C:

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

 int main(void)
 {
    /* request auto detection */
    int gdriver = DETECT, gmode, errorcode;

    /* initialize graphics mode */
    initgraph(&gdriver, &gmode, "");

    /* read result of initialization */
    errorcode = graphresult();

    if (errorcode != grOk)  /* an error occurred */
    {
       printf("Graphics error: %s\n", grapherrormsg(errorcode));
       printf("Press any key to halt:");
       getch();
       exit(1);             /* return with error code */
    }

    /* draw a line */
    line(0, 0, getmaxx(), getmaxy());

    /* clean up */
    getch();
    closegraph();
    return 0;
 }

Edited 5 Years Ago by Adak: n/a

Chill brother! Just copy the contents of the BGI folder to the BIN folder and then run your Graphics Programs... Trust me they will execute. I too faced the same problem which was solved by my GENIUS friend, MITUL ISLAM. I thank him. ;)

This article has been dead for over six months. Start a new discussion instead.