Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

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

1 view
Skip to first unread message

risshahaprma

unread,
Jan 22, 2010, 11:56:49 PM1/22/10
to rissha...@gmail.com
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

Keith Thompson

unread,
Jan 23, 2010, 12:30:55 AM1/23/10
to

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.

--
Keith Thompson (The_Other_Keith) ks...@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"

BGB / cr88192

unread,
Jan 23, 2010, 11:40:43 AM1/23/10
to

"risshahaprma" <sharma...@gmail.com> wrote in message
news:9d5d774d-4a5e-4300...@k35g2000yqb.googlegroups.com...

>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...

Paul N

unread,
Jan 24, 2010, 3:54:05 PM1/24/10
to
On 23 Jan, 04:56, risshahaprma <sharmaris...@gmail.com> wrote:

(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.

0 new messages