GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 05-Nov-2006, 14:11
abakws abakws is offline
New Member
 
Join Date: Oct 2006
Posts: 18
abakws is on a distinguished road

errors when compiling 'line example' from help > index


lately i reinstalled my borlandc++ 3.1 with graphics.h included and i tried to compile the 'line example' found in help > index and here is the result:



i made a screenshot because i couldnt copy error descriptions/line example to windows clipboard. does anybody know why do i get those errors and how to fix them? thanx in advance.
  #2  
Old 05-Nov-2006, 14:25
ubergeek ubergeek is offline
Regular Member
 
Join Date: Jan 2005
Posts: 775
ubergeek is a jewel in the roughubergeek is a jewel in the roughubergeek is a jewel in the rough

Re: errors when compiling 'line example' from help > index


You need to link with the corresponding library for graphics.h.
  #3  
Old 05-Nov-2006, 14:31
abakws abakws is offline
New Member
 
Join Date: Oct 2006
Posts: 18
abakws is on a distinguished road

Re: errors when compiling 'line example' from help > index


and how do i do that?
  #4  
Old 05-Nov-2006, 14:54
WaltP's Avatar
WaltP WaltP is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Midwest US
Posts: 3,258
WaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to all

Re: errors when compiling 'line example' from help > index


You have to compile the program with the graphics.lib library that came with the compiler. You need to find the place where the command line is defined and add the file.
__________________

Got a cough? Go home tonight and eat a whole box of Ex-Lax. Tomorrow, you'll be afraid to cough.
-- Pearl Williams
  #5  
Old 06-Nov-2006, 16:11
LuciWiz's Avatar
LuciWiz LuciWiz is offline
Moderator
 
Join Date: Jul 2004
Location: Cluj-Napoca (Romania)
Posts: 959
LuciWiz is a jewel in the roughLuciWiz is a jewel in the roughLuciWiz is a jewel in the roughLuciWiz is a jewel in the rough

Re: errors when compiling 'line example' from help > index


You can do it right from the menu :
access [Options]->[Linker]->[Libraries...] and check the [Graphics library] option.

High-school, cemetery of my youth (Emil Cioran).
__________________
Please read these Guidelines before posting on the forum

"A person who never made a mistake never tried anything new."
Einstein
  #6  
Old 06-Nov-2006, 16:16
abakws abakws is offline
New Member
 
Join Date: Oct 2006
Posts: 18
abakws is on a distinguished road

Re: errors when compiling 'line example' from help > index


multzam omule

CPP / C++ / C Code:
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>

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

   /* initialize graphics and local variables */
   initgraph(&gdriver, &gmode, "");

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

   setcolor(getmaxcolor());
   xmax = getmaxx();
   ymax = getmaxy();

   /* draw a diagonal line */
   line(0, 0, xmax, ymax);

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


now grapherrormsg(errorcode) returns "devide driver file not found (egavga.bgi)" i downloaded that file but i dont know where to place it to make that work... i tried in LIB directory, INCLUDES too but nothing... any ideeas?
Last edited by LuciWiz : 07-Nov-2006 at 02:09. Reason: Please insert your C/C++ code between [cpp] & [/cpp] tags
  #7  
Old 06-Nov-2006, 16:49
abakws abakws is offline
New Member
 
Join Date: Oct 2006
Posts: 18
abakws is on a distinguished road

Re: errors when compiling 'line example' from help > index


ok i found where to install that egavga.bgi file (lol bgi folder was right under my nose) but still i get that err
  #8  
Old 07-Nov-2006, 02:16
LuciWiz's Avatar
LuciWiz LuciWiz is offline
Moderator
 
Join Date: Jul 2004
Location: Cluj-Napoca (Romania)
Posts: 959
LuciWiz is a jewel in the roughLuciWiz is a jewel in the roughLuciWiz is a jewel in the roughLuciWiz is a jewel in the rough

Re: errors when compiling 'line example' from help > index


Quote:
Originally Posted by abakws
CPP / C++ / C Code:
initgraph(&gdriver, &gmode, "");

You must give the correct path to the file, something like "c:\\bc\\bgi", or whatever applies in your case.
__________________
Please read these Guidelines before posting on the forum

"A person who never made a mistake never tried anything new."
Einstein
  #9  
Old 07-Nov-2006, 13:08
abakws abakws is offline
New Member
 
Join Date: Oct 2006
Posts: 18
abakws is on a distinguished road

Re: errors when compiling 'line example' from help > index


ok i tried but the same thing here is the code:

CPP / C++ / C Code:
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>

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

   /* initialize graphics and local variables */
   initgraph(&gdriver, &gmode, "C:\\BCPP31\\BGI");

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

   setcolor(getmaxcolor());
   xmax = getmaxx();
   ymax = getmaxy();

   /* draw a diagonal line */
   line(0, 0, xmax, ymax);

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

i tried "c:\\bcpp31\\bgi\\egavga.bgi" too but still... the same thing
Last edited by LuciWiz : 07-Nov-2006 at 14:34. Reason: Please insert your C/C++ code between [cpp] & [/cpp] tags
  #10  
Old 09-Nov-2006, 04:40
infocalc5 infocalc5 is offline
New Member
 
Join Date: Oct 2006
Posts: 2
infocalc5 is on a distinguished road

Re: errors when compiling 'line example' from help > index


same problem here pls help
 
 

Recent GIDBlogStupid Management Policies by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
getting an error while compiling and running using different IDE. jaro C Programming Language 0 25-Aug-2006 10:14
In Need of Some Serious Help...compiling errors [C++] needcishelp C++ Forum 25 21-Dec-2005 02:26
CD burner wont burn!! robertli55 Computer Hardware Forum 1 18-Jun-2004 11:53
Yet another CD burner problem: Lite-On LSC-24082K Erwin Computer Hardware Forum 1 22-May-2004 12:28
CD Buring Failed skanth2000 Computer Hardware Forum 1 15-Nov-2003 04:52

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 14:42.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.