C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

class library in c++
Goto page 1, 2  Next
 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++)
View previous topic :: View next topic  
Author Message
pooja
Guest





PostPosted: Thu Sep 29, 2005 11:40 am    Post subject: class library in c++ Reply with quote



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

Back to top
EventHelix.com
Guest





PostPosted: Thu Sep 29, 2005 11:53 am    Post subject: Re: class library in c++ Reply with quote



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

Back to top
pooja
Guest





PostPosted: Fri Sep 30, 2005 9:30 am    Post subject: Re: class library in c++ Reply with quote



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.

Back to top
EventHelix.com
Guest





PostPosted: Fri Sep 30, 2005 12:08 pm    Post subject: Re: class library in c++ Reply with quote

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

Back to top
E. Robert Tisdale
Guest





PostPosted: Fri Sep 30, 2005 3:51 pm    Post subject: Re: class library in c++ Reply with quote

pooja wrote:

Quote:
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.

Back to top
pooja
Guest





PostPosted: Sat Oct 01, 2005 11:08 am    Post subject: Re: class library in c++ Reply with quote

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

Back to top
John Harrison
Guest





PostPosted: Sat Oct 01, 2005 12:29 pm    Post subject: Re: class library in c++ Reply with quote

pooja wrote:
Quote:
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.


Quote:
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

Back to top
pooja
Guest





PostPosted: Mon Oct 03, 2005 6:09 am    Post subject: Re: class library in c++ Reply with quote

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?

Back to top
Kai-Uwe Bux
Guest





PostPosted: Mon Oct 03, 2005 7:10 am    Post subject: Re: class library in c++ Reply with quote

pooja wrote:

Quote:
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

Back to top
pooja
Guest





PostPosted: Mon Oct 03, 2005 9:11 am    Post subject: Re: class library in c++ Reply with quote

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?

Back to top
Karl Heinz Buchegger
Guest





PostPosted: Mon Oct 03, 2005 11:17 am    Post subject: Re: class library in c++ Reply with quote

pooja wrote:
Quote:

Ok thanks , but still some confussion is there

suppose I have created a file "abcd.h" like this
//abcd.h
#inlcude 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
[email]kbuchegg (AT) gascad (DOT) at[/email]

Back to top
pooja
Guest





PostPosted: Mon Oct 03, 2005 12:08 pm    Post subject: Re: class library in c++ Reply with quote

"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?

Back to top
Karl Heinz Buchegger
Guest





PostPosted: Mon Oct 03, 2005 2:58 pm    Post subject: Re: class library in c++ Reply with quote

pooja wrote:
Quote:

"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 :-)

Quote:

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 #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
[email]kbuchegg (AT) gascad (DOT) at[/email]

Back to top
pooja
Guest





PostPosted: Tue Oct 04, 2005 6:23 am    Post subject: Re: class library in c++ Reply with quote

Thank you so much. I am really thank full to you for solving my problem
so nicely and so beautifully.



Karl Heinz Buchegger wrote:
Quote:
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 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 #include
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
[email]kbuchegg (AT) gascad (DOT) at[/email]


Back to top
pooja
Guest





PostPosted: Tue Oct 04, 2005 7:56 am    Post subject: Re: class library in c++ Reply with quote

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.

Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++) All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.