Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Unrecognized recognized function.

Posted on 2001-08-06
13
Medium Priority
?
299 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
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

972 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