Solved

Unrecognized recognized function.

Posted on 2001-08-06
13
287 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
 

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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
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 use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

707 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now