[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now


BCB3: "library": how to implement?

Posted on 1998-04-18
Medium Priority
Last Modified: 2010-04-10
Ok... So it's not that difficult, but here's my background:

1) I took C language in college 7 yrs ago. They never taught me "Libraries/Drivers".
2) I'm a pascal/Delphi fan... That's one of the reasons I chose BC++Builder 3.

I have a TCP/IP programming assignment due in a few days. In the assignment it states "A "driver" or library module should be coded that has the following ...". So, I thinking...

"oh, that just a "unit" (from delphi)".. So I go to File/New Unit.. menu and start adding my functions that I need after #pragma package(smart_init)...
Welp... Great! I think... So I go into my new form and put
#include "rup_libary.h" at the top. So far so good... Now I start adding code to a button... in that code I need to call one of my functions that exist in the "library" called rup_close();

I goto "build" the program and bamm!... I get the following error:

[C++Error] serverfrm.cpp(22): Call to undefined function 'rup_close'.

So... How do I create a "Library" that can be seen from my form code? I'd rather not create a class if possible.

Any help would be greatly appreciated!
Question by:zitt
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
  • 4
  • 3
LVL 22

Expert Comment

ID: 1161933
Its hard to understand from what you've said.  but it sounds like you defined the close function and other functions in a source code file.  (.cpp)  but when you go to use them you are including a header file (.h).  You need to declare the function in the .h file.  (But you can still define them in the .cpp file).

Author Comment

ID: 1161934
Okay... So, Can I #include "rup_libary.cpp"?

Is it illegal to have only a .h file with no .cpp file?

Sorry, I'm totally new to creating my own libraries in C.

LVL 22

Expert Comment

ID: 1161935
yes, you can place the function definition (that is the body of the function) in a .cpp file and include the file.  That will work, but is very unusual.  Usually you would compile the .cpp file to produce a .obj file in one project.  Then in another project you would link in the obj file (byt adding it to the project).  And you would include a .h into this project's source file.  This .h has only the function declarations, not the definitions.  That is has the function's return value, name and parameters, but no body.
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.


Author Comment

ID: 1161936
The end result is these functions in my "library" will be under constant work. I'd like to be able to debug each function as I add functionality to them.

For example, under Delphi... I can make changes on the fly to a unit and the new code would be there. I'm just having a hard time understanding why does it differently.
LVL 22

Expert Comment

ID: 1161937
That should be the same under BCB3.  (Its exactly the case I have.) What your would do is create a project group that has two projects.  One project is for the library (In my case a DLL library.  But it could be an OBJ library if you want)  The other project is for an EXE that uses the library.  The EXE library should be the second project in the project group (You can use the "build sooner"/"build later" commands to control the positions.  The EXE should be built last.)  You should compile using the make all projects command.  This will check for changes to the library project and recompile/relink it if needed and then  do the same for the EXE project.  The EXE project should have at least two things under it.  One is the source code (.cpp) file  The other thing is the output file of the library project.  In my case a .LIB file, in your case a .OBJ file.

Has this been of any help to you?
LVL 22

Accepted Solution

nietod earned 60 total points
ID: 1161938
Was this helpful? Do you need more?

Author Comment

ID: 1161939

Thanks for all your help... I'm not sure what the hang up was... but I got the library working...


Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
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++.
Suggested Courses

650 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