Sign in to follow this  

Writing .LIB files...? (C++)

This topic is 3296 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

I want to write a series of functions to work with char arrays. I was wondering if I could put them in a LIB file, but I don't know what makes them unique from other C++ areas. Is there a certain syntax to write them in, is there some sort of import/export interface like a DLL? I know nothing about them, so can I a brief explanation?

Share this post


Link to post
Share on other sites
The only real difference of a lib over source code is that you can't see the source code in it and you have to link it instead of including it to your project.

If you're not distributing the .lib, I won't bother making one, it's really a waste of time and everytime you need to fix something with those function you have to re edit the libs source and recompile it.

libs are also compile into the exe just like the source code so if you're trying to make the exe smaller it won't help with that.

Share this post


Link to post
Share on other sites
Quote:
Original post by freeworld
The only real difference of a lib over source code is that you can't see the source code in it and you have to link it instead of including it to your project.

If you're not distributing the .lib, I won't bother making one, it's really a waste of time and everytime you need to fix something with those function you have to re edit the libs source and recompile it.

libs are also compile into the exe just like the source code so if you're trying to make the exe smaller it won't help with that.


However, because these LIB files are being used during compiling, the actual compile process will be shorter, depending on how much source is in the library. Considering the application I work on professionally, cutting it up in libraries makes the whole project compile much faster, because it only has to recompile the parts that have changed.

And that's one of the reasons people use static libraries.

MSN Article on how to create and use static libraries in Visual Studio

Toolmaker

Share this post


Link to post
Share on other sites
Agreed with Toolmaker, at work we have a very strictly apportioned bunch of libs, some of which do get changed but most of them are almost entirely untouched and hence almost never get recompiled - huge benefit for a large codebase.

If you're completely happy with a bunch of classes that pass all your tests and you think you'll get a lot of reuse from then by all means compile them up into a lib, particularly if they're related to each other such that they work together as a closed module (quite nebulous definition of course.)

Share this post


Link to post
Share on other sites

This topic is 3296 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.

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