Facing problem even in basic C++ graphics programs compilation!!!HELP

R

risshahaprma

I made a simple program to draw line but it gives errors.I am not able
to debug them and feeling frustrated as I canna even get myself
started for graphics ! When I used the same code in my computer lab it
worked fine..Plz help..I would really appreciate your response!


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

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

/* initialize graphics mode */
initgraph(&gdriver, &gmode, "c:/tc/bgi");

/* draw a line */
line(0, 0, 400, 400);
getch();
return 0;
}
error 1:undefined symbol _line in module ris.cpp

error 2:undefined symbol _initgraph in module ris.cpp
 
K

Keith Thompson

risshahaprma said:
I made a simple program to draw line but it gives errors.I am not able
to debug them and feeling frustrated as I canna even get myself
started for graphics ! When I used the same code in my computer lab it
worked fine..Plz help..I would really appreciate your response!


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

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

/* initialize graphics mode */
initgraph(&gdriver, &gmode, "c:/tc/bgi");

/* draw a line */
line(0, 0, 400, 400);
getch();
return 0;
}
error 1:undefined symbol _line in module ris.cpp

error 2:undefined symbol _initgraph in module ris.cpp

This is comp.lang.c; comp.lang.c++ is down the hall on the left.

But you'd probably run into the same problem if you were using C, so
I'll try to give you a hint or two.

Neither <graphics.h> nor <conio.h> is a standard header in either
C or C++. They're probably provided by your implementation.
Since your code compiles, you apparently have the headers available
both in your computer lab and wherever else you're trying this (you
didn't say). Errors like "undefined symbol" are typically produced
by the linker, and can indicate that you didn't tell the linker
where to find the required library or libraries. Probably whatever
library is associated with the header <graphics.h> is the culprit.
I don't know how to tell the linker (whichever one you're using)
to load that library (whatever it is); you'll have to find that
out elsewhere, either by reading your system's documentation or by
asking in another forum.

Note that the folks in comp.lang.c++, though they know plenty about
the C++ language, are no more likely than we are to know about this
<graphics.h> header or its associated library.
 
B

BGB / cr88192

risshahaprma said:
I made a simple program to draw line but it gives errors.I am not able
to debug them and feeling frustrated as I canna even get myself
started for graphics ! When I used the same code in my computer lab it
worked fine..Plz help..I would really appreciate your response!
<snip>

looks like Borland C or Turbo C...

either way, note that code specific to these compilers will not work
anywhere else, and FWIW, this code uses Borland-specific extensions...

so, if one wants portable code, write portable code...
 
P

Paul N

(snip)
error 1:undefined symbol _line in module ris.cpp

error 2:undefined symbol _initgraph in module ris.cpp

If you're using Turbo C++, then the instructions in my manual are as
follows:

If you're using the IDE, make sure full menus are on, go to Options /
Linker and check Graphics library.

If you're using the command line, use tcc myprog graphics.lib

Hope this helps. If it doesn't, you'll have to try a group relevant to
your system.
Paul.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top