Solved

Unrecognized recognized function.

Posted on 2001-08-06
13
292 Views
Last Modified: 2012-06-27
While attempting to learn C++ through DOS (all attempts at windows programming have exasperated me to tears), I pulled out Borland C++ 4.52, set my TargetExpert to a standard DOS application and tried to call some simple functions from graphics.h. None of the functions in graphics.h are recognized by the compiler. For example, rectangle(1,2,3,4) gives the error "undefined symbol _rectangle() in [current module]". But if I call the function with the wrong number of parameters (rectangle(1,2,3,4,5) it states that it knows I've used the wrong number of parameters.

What have I done wrong /now/?
0
Comment
Question by:Decimal
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 3
  • +1
13 Comments
 
LVL 4

Expert Comment

by:sdussinger
ID: 6358110
If you post some of your code, it'll certainly be easier to figure it out.

--Steve
0
 
LVL 1

Expert Comment

by:Aggarwal
ID: 6358147
It's because it can find the Header file at the compile time.So, it can perform the type checking !!
That is when u pass wrong nunmber of parameters it can trace it at the compile time/

When you are passing correct params..it's going thru the compilation phase..

Now the problem is coming at the time of linking. Probably u are not specifying graphics lib !!!

something similar ..to

YourComp a.cpp -lgraphics

Make sure to specify ur graphics lib !!!
0
 
LVL 1

Expert Comment

by:Aggarwal
ID: 6358187
Finally there are two cases !!!

1. Correct Nos of paramaters ->
Problem - linking error ..
Solution - specify the graphics lib used while Compiling/Linking

2. Passing wrong nos of Param ->
Problem - Compilation error

Hope this solves your problem !!

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Decimal
ID: 6358211
Builder doesn't have a command line option, I don't think. So "YourComp a.cpp -lgraphics" or whatever is out of the question (even if I understood what you just said.)

Could you please reiterate it a bit simpler for the beginner?
How do I specify the graphics library used while compiling/Linking other than #include <graphics.h>?
0
 
LVL 1

Expert Comment

by:Aggarwal
ID: 6358229
decimal,

when we include some header ..
It means contents of that particular file are included in this file..Which simply means contents of graphics.h are now copied into ur C/CPP file./

Now say u have n cpp files ..then all cpp files are compiled to generate obj files ..which are then linked ( which means linking all the obj files and libraries used)..

Now lets come back to the problem !!

say u have one file a.cpp and it looks like //

#include<graphics.h>

int main ( void )
{
   ...
   rectangle(10,20,30,40) ; // Case 1
   rectangle(10,20,30,40,50); // Case 2
   ...
   return 0 ;
}
// End of file
Case 1: passing Correct parameters ..compiling phase Okay no Error ..Now problems while linking ..because it could not find the definition of rectangle function declared in graphics.h ..and there will be a library having definition of this function which u need to specify.

Case2 : passing wrong Number of Params ->
Here compilation phase can find the problem because there is no function available with matching signature !!!
So, it's a compilation error ..Didn't go to the linking phase.

Never used Builder ..There must be some option where u can specify the libs to be included ..

something like ..

C:>bcc a.c -lmath

Here we are saying link math library !!

Cheers
aggarwal
0
 

Author Comment

by:Decimal
ID: 6358236
Builder doesn't have a command line option, I don't think. So "YourComp a.cpp -lgraphics" or whatever is out of the question (even if I understood what you just said.)

Could you please reiterate it a bit simpler for the beginner?
How do I specify the graphics library used while compiling/Linking other than #include <graphics.h>?
0
 

Author Comment

by:Decimal
ID: 6358252
I'll do a little looking. Still register a blank when you state a command line phrase, though. What I don't understand is why the graphics.h library wouldn't function like any other library, say conio.h or stdlib.h?
0
 
LVL 4

Expert Comment

by:sdussinger
ID: 6358265
conio.h and stdio.h are part of the default C/C++ libraries. They define function which can be found in libc or libcpp. These libraries are loaded by default by most modern compilers.

The difference here is that you're trying to load something from graphics.h, which is not part of the default libraries. You need to tell your development environment where to find this library.

Somewhere in your IDE (I've not used Borland, so I can't tell you exactly where), there will be a mechanism for adding new libraries when you build your program. Try looking in the Borland help for any information on libraries. It'll probably tell you where in the IDE to go to add a new library for building your program.

--Steve
0
 
LVL 1

Expert Comment

by:Aggarwal
ID: 6358278
See conio.h and stdlib.h are not libraries ..

Definitions of all the functions provided in these header files is a part of standard C lib. ( libc.a on unix )
may be stdlib on ur system !! That standard C library is always included at the time of linking that's why it's working !!

And Grpahics is not a part of standard C library !!!
So, you need to link to the proper library !!!

In VC environment !! i can tell you how to do that ..on unix i can explain ..Never used Borland Builder
0
 
LVL 1

Expert Comment

by:Aggarwal
ID: 6358280
Sorry Steve ,

For posting similar comments !!!
But , i could see ur comments after my Post !!

Regards,
Aggarwal
0
 
LVL 4

Expert Comment

by:sdussinger
ID: 6358288
No problem... ;-)

--Steve
0
 
LVL 14

Accepted Solution

by:
AlexVirochovsky earned 192 total points
ID: 6358984
Do you set "BGI" flag in your project?
>>all attempts at windows programming have exasperated me to tears
And I recomend you use Windows. DOS is dead, you need learn
Windows programming, it is not easy, may be, but you hav't
choise! Use, for example, classic Petzold's book, or
one of next online tutorials:

http://bcgrizzly.com/~forger/winprog/tutorial/
Relisoft (C++) : http://www.relisoft.com/index.htm
http://www.cs.binghamton.edu/~reckert/360/360notes.html
http://www.dum.chalmers.se/~amag/wintut/index.html
0
 

Author Comment

by:Decimal
ID: 6362111
Great, it works! Thanks to everybody who answered. I didn't think I would need to do any command line editing through Builder... now I just need to figure out what that BGI thing is. =)

Thanks!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question