Undefined symbol in Borland C++ 3.1

I'm trying to do some easy graphics but I'm not understanding this error I keep getting.  First off, the program works fine in my old Borland C compiler (it came on a single disk in a textbook, a limited version 2.0 I think...) so I know the code is error free.  I've installed Borland C++ 3.1 because the IDE is more _modern_ believe it or not!  Here's the program, what little there is, and the errors follow...


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

void main( void )
{
      int graph_driver;
      int graph_mode;
      graph_driver = VGA;
      graph_mode = VGAHI;  

      initgraph( &graph_driver, &graph_mode,"c:\\borlandc\\bgi" );

      putpixel(100,100,1);

}


Linker Error: Undefined symbol _initgraph in module ..

Linker Error:  Undefined symbol _putpixel in module ..
 

Like I said it works fine in my very old compiler, its just in the C++ 3.1 compiler in which it fails.  I copied the egavga.bgi file to the directory with the source code so I don't think that's the problem.  I'm thinking maybe I haven't set up the compiler correctly (?)  I don't know since this is the only real one I have.  If anyone can tell me why its giving me undefined symbol errors and how I can fix them (in normal speak, I'm still learning the lingo) I've added a massive amount of points.  Thanks in advance!
claycombAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
AlexVirochovskyConnect With a Mentor Commented:
You must add in you project file
graphics.lib
For this
1.Open Project Window: Alt + W, P
2. Press INS  
3. Type C:\borlandc\lib\graphics.lib
  in Name (or chouse from list)
4. Enter
5. Translate, make
Alex
0
 
bhatCommented:
HI,

Check for the include directories under the Options menu item.
Check for the graphics.h file.

Hope this helps
0
 
chensuCommented:
You need to link with the graphics library. bgi.lib? or graphics.lib?
0
 
claycombAuthor Commented:
Thanks Alex you led me to what was wrong, I probably wouldn't have found it otherwise so I'll give you the points real quick.  It seems that the Linker didn't have Graphics Library included.  (That's just how the IDE installed on my machine by default, I don't know why...)  Im just wondering though, before I award and finish off this question, if you (or anyone else) can explain why I have to adjust settings in the Linker.  Why isn't it enough to just have #include and give it a header file.  I have the location of the include files set correctly in the program preferences so why isn't this enough in itself?  Why would you want the linker to NOT include graphics files, that option doesn't make any sense to me.  I'm trying to understand _why_ this happens and not just _how_.
0
 
AlexVirochovskyCommented:
This depends of you setting.
By default,  graphics.lib not linked(and i 've described you metod, how you can add every .lib file). If you
want change setting, make this:
1. Alt + O(options), Linker, Libraries.
2. You see in Libraries SubWindow
  Graphics Library
  Turbo Vision.
Set flag in  Graphics Library
and Borland automtically find graphics.lib (and you must delete
graphics.lib from project file:
Alt + W, P, set line to this item
and press Del)
Why by default this flag not set?
Hard speak instead of Borland teem,
but may be they think as:
Most of programms with BC 3.1 in DOS
don't use graphics! In this case
graphics.lib is only unutile addition
in exe file, get place and don't make
nothing. And not every programmist changes default settings.
0
All Courses

From novice to tech pro — start learning today.