Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 300
  • Last Modified:

Unrecognized recognized function.

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
Decimal
Asked:
Decimal
  • 5
  • 4
  • 3
  • +1
1 Solution
 
sdussingerCommented:
If you post some of your code, it'll certainly be easier to figure it out.

--Steve
0
 
AggarwalCommented:
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
 
AggarwalCommented:
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
Technology Partners: 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!

 
DecimalAuthor Commented:
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
 
AggarwalCommented:
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
 
DecimalAuthor Commented:
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
 
DecimalAuthor Commented:
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
 
sdussingerCommented:
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
 
AggarwalCommented:
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
 
AggarwalCommented:
Sorry Steve ,

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

Regards,
Aggarwal
0
 
sdussingerCommented:
No problem... ;-)

--Steve
0
 
AlexVirochovskyCommented:
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
 
DecimalAuthor Commented:
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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 5
  • 4
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now