473,406 Members | 2,390 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

class library in c++

what is a class library and how does it different from c++ header file?

Sep 29 '05 #1
20 1769
In general, a class library would consist of several header files and
the associated source files.

--
EventStudio System Designer 2.5 - http://www.EventHelix.com/EventStudio
Sequence Diagram Based System Design and Modeling Tool

Sep 29 '05 #2
thanks.
Tell me one more thing , that how can I hide my header files and other
source file in a class library, so that my client would not be able to
open it and can not tamper the classes with in it.

Sep 30 '05 #3
Search Google for "c++ code obfuscator".

For source files, you could just ship the object files.

--
EventStudio System Designer 2.5 - http://www.EventHelix.com/EventStudio

Sequence Diagram Based System Design and Modeling Tool

Sep 30 '05 #4
pooja wrote:
Tell me one more thing,
"How can I hide my header files and other source file in a class library
so that my client would not be able to open it
and can not tamper the classes with in it?"


You can't.
You *must* distribute the header files
which define the public interface for the library.
Developers who distribute proprietary libraries
distribute object files in library archives
and *not* the source files which define the implementation.
You can do this too if you can compile your library
for every target platform.
Sep 30 '05 #5
how can I distribute the header files
which define the public interface for the library.?
how does Developers distribute proprietary libraries
distribute object files in library archives
and *not* the source files which define the implementation.
Tell me the code snippet for it.
also teel me the site from where i can get the information

Oct 1 '05 #6
pooja wrote:
how can I distribute the header files
which define the public interface for the library.?
how does Developers distribute proprietary libraries
distribute object files in library archives
and *not* the source files which define the implementation.
That depends on your toolset. For instance on Unix you might use the
'ar' command. With Microsoft VC++ you might use the 'lib' command.

Tell me the code snippet for it.
also teel me the site from where i can get the information


There is no code snippet. You just write the code as normal, make a
library from it. Then send the library and the header files to whoever
wants to use the library.

You get the information by reading the documentation that comes with
your compiler and other tools.

john
Oct 1 '05 #7
Can we develop library files and header files in a way so that it can
not be tampered by the programmers by using Turbo C and Borland C
compiler?

Oct 3 '05 #8
pooja wrote:
Can we develop library files and header files in a way so that it can
not be tampered by the programmers by using Turbo C and Borland C
compiler?


The library file is compiled already. Without access to the sources, your
customers will not be inclined to change. (The obvious path of changing a
library file is to recompile the source. This path is blocked if your keep
the source. Non-obvious paths of changing the binary exist, but the few who
can do that, you cannot stop.)

As for the headers, your customers would not use the compiler to "tamper"
with the header. They would just use their favorite text editor and change
it. More likely, however, they would create a different version and then
include their file rather than yours. Nothing forces a user to tell the
compiler about your header just because he intends to tell the linker about
your library. The compiler has no premonitions, it simply does not know
about the linker.

Also, why would that be of your concern? Keep in mind that, since their
version still would have to match the library file, they cannot really
depart very much. However, they could put certain identifiers into a
different namespace. Actually, your customers might have a very legitimate
reason for doing exactly that: it could be the only way to avoid conflicts
arising from the use of several libraries.
Best

Kai-Uwe Bux
Oct 3 '05 #9
Ok thanks , but still some confussion is there

suppose I have created a file "abcd.h" like this
//abcd.h
#inlcude<iostream.h>
class c1
{
public:
void sum()
{
cout<<"I am sum function";
}
};

now I created another file "file1.cpp" , in which I included this
"abcd.h" file.
//file1.cpp
#include"abcd.h"
void main()
{
c1 obj;
obj.sum();
}

I want that my customer would also use "abcd.h" header file as I am
using it in the above file1.cpp.
Tell me how should I distribute "abcd.h" to my programmer using TC as a
compiler.
Can I Simply copy it on a CD and hand it to the customer or so some
other steps are there?

Oct 3 '05 #10
pooja wrote:

Ok thanks , but still some confussion is there

suppose I have created a file "abcd.h" like this
//abcd.h
#inlcude<iostream.h>
class c1
{
public:
void sum()
{
cout<<"I am sum function";
}
};

now I created another file "file1.cpp" , in which I included this
"abcd.h" file.
//file1.cpp
#include"abcd.h"
void main()
{
c1 obj;
obj.sum();
}

I want that my customer would also use "abcd.h" header file as I am
using it in the above file1.cpp.

Tell me how should I distribute "abcd.h" to my programmer using TC as a
compiler.
Can I Simply copy it on a CD and hand it to the customer or so some
other steps are there?


In this case: copy it to the CD and you are fine.

--
Karl Heinz Buchegger
kb******@gascad.at
Oct 3 '05 #11
"In this case: copy it to the CD and you are fine. "
and what would be the other case?

How to create a header file and packaged it , so that my customer would
not be able to the see the functions and their implementation?

Oct 3 '05 #12
pooja wrote:

"In this case: copy it to the CD and you are fine. "
and what would be the other case?
The other case would be to have no function implementations
in the header file :-)

How to create a header file and packaged it , so that my customer would
not be able to the see the functions and their implementation?


Your case was:

#inlcude<iostream.h>
class c1
{
public:
void sum()
{
cout<<"I am sum function";
}
};

and you want to ship that to your customer.
But this is not the likaly case. You may have some functions the user can see, but
this is not the usual case.
The much more usual case would be this:

abcd.h
******

#ifndef ABCD_H_
#define ABCD_H_

class c1
{
public:
void sum();
};

#endif

abcd.cpp
********

#include <iostream>
#include <abcd.h>

void c1::sum()
{
std::cout << "I am sum function";
}
Now you compiler abcd.cpp with the compiler of your choice (and most always
needs to be the same compiler your customer uses). If there are more then 1
cpp files, you will want to collect all those object files (the results of
all the individual compiler runs) into a library. You then ship to your customer:
* the header file he needs (abcd.h in the above example)
* the object file (or the library)

Now you customer writes:

#include "abcd.h" // that is why he needs to have the header file
int main()
{
c1 obj;
obj.sum();
}

and links it with the object file (or the library) you provide.

Things to note:
* You have to supply the header file, because your customer needs it
* Whatever you write in the header file is visible to your customer. Thus
you may want to reduce this to a minimum. This is eg. why I moved the implementation
from abcd.h into another file which gets compiled and shipped in its compiled form.
* Depending on your platform and/or compiler you might be forced to compile the library
for different platforms/compilers and ship a customized version to your customer.

--
Karl Heinz Buchegger
kb******@gascad.at
Oct 3 '05 #13
Thank you so much. I am really thank full to you for solving my problem
so nicely and so beautifully.

Karl Heinz Buchegger wrote:
pooja wrote:

"In this case: copy it to the CD and you are fine. "
and what would be the other case?


The other case would be to have no function implementations
in the header file :-)

How to create a header file and packaged it , so that my customer would
not be able to the see the functions and their implementation?


Your case was:

#inlcude<iostream.h>
class c1
{
public:
void sum()
{
cout<<"I am sum function";
}
};

and you want to ship that to your customer.
But this is not the likaly case. You may have some functions the user can see, but
this is not the usual case.
The much more usual case would be this:

abcd.h
******

#ifndef ABCD_H_
#define ABCD_H_

class c1
{
public:
void sum();
};

#endif

abcd.cpp
********

#include <iostream>
#include <abcd.h>

void c1::sum()
{
std::cout << "I am sum function";
}
Now you compiler abcd.cpp with the compiler of your choice (and most always
needs to be the same compiler your customer uses). If there are more then 1
cpp files, you will want to collect all those object files (the results of
all the individual compiler runs) into a library. You then ship to your customer:
* the header file he needs (abcd.h in the above example)
* the object file (or the library)

Now you customer writes:

#include "abcd.h" // that is why he needs to have the header file
int main()
{
c1 obj;
obj.sum();
}

and links it with the object file (or the library) you provide.

Things to note:
* You have to supply the header file, because your customer needs it
* Whatever you write in the header file is visible to your customer. Thus
you may want to reduce this to a minimum. This is eg. why I moved the implementation
from abcd.h into another file which gets compiled and shipped in its compiled form.
* Depending on your platform and/or compiler you might be forced to compile the library
for different platforms/compilers and ship a customized version to your customer.

--
Karl Heinz Buchegger
kb******@gascad.at


Oct 4 '05 #14
Thanks for clearing my doubts.
But there is a problem , that when I execute this code, at run time the
compiler shows an error message " undefined symbol c1::sum() in module
file1.cpp."

I have copied abcd.obj, abcd.h and file1.cpp(in which I have written
thye main()) in TCTEMP folder, and in this folder all other necessary
libraries, header files are present.
So why it is showing this error message?
How to solve this problem.

Oct 4 '05 #15
pooja wrote:

Thanks for clearing my doubts.
But there is a problem , that when I execute this code, at run time the
compiler shows an error message " undefined symbol c1::sum() in module
file1.cpp."
Is it really a compiler error message? Looks more like a linker error
message to me.

I have copied abcd.obj, abcd.h and file1.cpp(in which I have written
thye main()) in TCTEMP folder, and in this folder all other necessary
libraries, header files are present.
So why it is showing this error message?
Did you tell your linker that it should include abcd.obj when it builds
the executable?
How to solve this problem.


Depends on your actual compiler/linker system what you need to do in order
to specify what needs to be linked to form the final executable.

--
Karl Heinz Buchegger
kb******@gascad.at
Oct 4 '05 #16
I am using Turbo C compiler ,tell me how to link these obj files at
runtime. In UNIX I am able to do this. but in TC I don't know how to do
it. Tell me the how should I do.

Oct 6 '05 #17
pooja wrote:

I am using Turbo C compiler ,tell me how to link these obj files at
runtime. In UNIX I am able to do this. but in TC I don't know how to do
it. Tell me the how should I do.


Sorry. I can't, since I don't know Turbo C.
But I am pretty sure that somewhere there is a newsgroup dealing
with that particular compiler.

(Did you read the documentation that came with your compiler?
Are there same example projects included with your compiler? Sometimes
studying examples sheds a lot of light on things.)
--
Karl Heinz Buchegger
kb******@gascad.at
Oct 6 '05 #18
ok no problem . thanks any way for showing your kind attention towards
this topic , and clearing my doubts.

Oct 6 '05 #19

"pooja" <wa******@gmail.com> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com...
I am using Turbo C compiler ,tell me how to link these obj files at
runtime. In UNIX I am able to do this. but in TC I don't know how to do
it. Tell me the how should I do.

From the project menu, choose "Add Item", then just double click on the .obj
file. You may have to edit the default dialog box to show all files in the
directory. (change *.prj to *.*, or whatever)

It will then link automatically when you compile.

Oct 7 '05 #20
I have some .cpp , obj and .h files but they are not includded in any
projcet. Is it necessary to include all of them in a project, so that
at run time linker can find all the necessary .obj files. If yes then
how to create a project and add all these files?

Also When I click on project menu, only "open project" option is
highlighted, rest of the options are unhighlighted. so how to proceed
further?

Oct 8 '05 #21

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

20
by: syd | last post by:
In my project, I've got dozens of similar classes with hundreds of description variables in each. In my illustrative example below, I have a Library class that contains a list of Nation classes. ...
6
by: Patrick | last post by:
Following earlier discussions about invoking a .NET class library via ..NET-COM Interop (using regasm /tlb) at...
4
by: Brian Shannon | last post by:
I am playing around with class libraries trying to understand how they work. I created a class library, library.vb. I placed the library.dll into the bin directory and set my reference. If I...
3
by: eBob.com | last post by:
I have several applications which mine web sites for personal information which they publish. They publish the info in one form, I transform the info into Excel spreadsheets. So all these...
5
by: Tony Johansson | last post by:
Hello! I have one solution file that consist of three project. One project that build the exe file called A One project that build a user control dll. Here we have a class called B One project...
0
by: tony | last post by:
Hello! I have one solution file that consist of three project. One project that build the exe file called A One project that build a user control dll. In this user control we have a class...
5
by: tony | last post by:
Hello! This is a rather long mail but it's a very interesting one. I hope you read it. I have tried several times to get an answer to this mail but I have not get any answer saying something...
5
by: Rainer Queck | last post by:
Hello NG, Is it possible to share the settings of an application with a class libreary? In my case I have a application and a set of different reports (home made) put into a class library. The...
0
by: drawing in aspnet | last post by:
Question about putting the data layer in a separate class library. I keep reading that the data layer should be separated from the presentation layer and put in its own class library. I am...
4
by: Steve Baer | last post by:
I've already tested this with C# and it works, but I'm being paranoid and I wanted to also check here. Our application has a large class library written in C++/CLI for plug-in projects. The...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.