Static library questions...

Started by
1 comment, last by iNsAn1tY 17 years, 5 months ago
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...
My opinion is a recombination and regurgitation of the opinions of those around me. I bring nothing new to the table, and as such, can be safely ignored.[ Useful things - Firefox | GLee | Boost | DevIL ]
Advertisement
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
Problem solved. I'll use an interface to the classes I want, and a pair of create/destroy functions inside my library. Thanks.
My opinion is a recombination and regurgitation of the opinions of those around me. I bring nothing new to the table, and as such, can be safely ignored.[ Useful things - Firefox | GLee | Boost | DevIL ]

This topic is closed to new replies.

Advertisement