Sign in to follow this  
iNsAn1tY

Static library questions...

Recommended Posts

iNsAn1tY    476
Evening all. I'm creating a static library for a project I'm working on at the moment. I'd like to hide as much of the implementation as possible, in order to avoid incorrect use of parts of the library. I am working in C++. I have a set of classes which I want the client program to be able to see and instantiate, and a set of classes which I want hidden. These classes reside within namespaces, and there will, most likely, be many couplings between them. Each class has a header file and an implementation file. If I create an include file to complement my library file, and include all of the header files for the set of classes I would like to be available to the client program, I will inevitably include header files for the classes I want to remain hidden. I suppose my question is this: can I define classes (and functions of certain classes) with __declspec( dllexport ) in their include files, then create an include file for my library and declare only those classes and class functions defined with __declspec( dllexport )? Is this the correct way of hiding implementation in a library? Thanks in advance for any replies...

Share this post


Link to post
Share on other sites
janta    345
Hello,

I believe that if you create a STATIC librairy (that is, usually a .lib file), you dont need to worry about declspec'ing your methods. Just output your .lib file and distribute it along with the definition file (usually .h)

Your end user will just have to include that .h file and add your librairy.lib to it's dependencies.

If you were talking about creating a dll then it would be somehow different.

- JA

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this