Jump to content
  • Advertisement
Sign in to follow this  
MajinMusashi

C++ static library creation

This topic is 4822 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi! I've created a text rendering engine (wrapper?) based on Sven Olsen FreeType tutorial (Nehe - Lesson 43). It works good at the moment, and I feel now is the time to pack it into a static library (since I'm using the same classes on some different projects). But man, I have so many questions. Please, take a look at the source and/or the image (overall library design) below: Source files Overall library design (the way the classes are arranged) - please interpret the arrows simply as "using" 1) As you can see from the image above, only "C_TextSingle" and "C_TextMulti" (both inherited from "C_TextBase") must be instantiable to the library users. How can I do that limitation? 2) Every header file (5) must be provided along with the library file or can I reorganize it so the user needs to include only one header file + library file (highly desirable)? The problem gets even worse because this library is a wrapper for the FreeType2 library (one library file + some headers) and uses SDL + OpenGL (two library files + many headers); Thanks a lot! I have found almost nothing on Google about more complex static libraries :( PS.: "C_FontManager" is a singleton; PS.: I'm using Visual C++ 6.0 + SDL + OpenGL + FreeType2

Share this post


Link to post
Share on other sites
Advertisement
This might be more of a tip for when exporting to a library format then a solution to your problem. You should probably namespace you classes/objects so that when you eventually distrubute them they don't have variable and type name conflicts.

Share this post


Link to post
Share on other sites
I usually just change the configuration of the workspace to a .lib in the general tab (in .NET) and I haven't had a problem yet. I don't remember if you need to include every header file (just a guess, I'd say yes). Someone correct me if I'm wrong. And namespaces are definately a good practice to get into.

Share this post


Link to post
Share on other sites
Quote:
Original post by njpaul
I usually just change the configuration of the workspace to a .lib in the general tab (in .NET) and I haven't had a problem yet.

No problem here. I know how to set up Visual C++ so it will generate a .LIB. I'm confused about the "internals" :)
Thanks anyway!

Share this post


Link to post
Share on other sites
Come on, guys! Help me...
By the way, I've found a trick to make some classes instantiable/reachable only inside/by some specific classes, what answers my second question. Example:

// Class A must be instantiable only by class B
class A {
private:
A();
public:
draw();
friend class B;
};

// Class B is the only one that can instantiate A
class B {
private:
A a;
};

int main() {
A a; // ERROR - A constructor is private!
}



Thanks, and please, give me some light about C++ static libraries :(

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!