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

Started by
3 comments, last by zyrolasting 15 years, 4 months ago
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?
Advertisement
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.
[ dev journal ]
[ current projects' videos ]
[ Zolo Project ]
I'm not mean, I just like to get to the point.
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

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.)

Visit http://www.mugsgames.com

Stroids, a retro style mini-game for Windows PC. http://barryskellern.itch.io/stroids

Mugs Games on Twitter: [twitter]MugsGames[/twitter] and Facebook: www.facebook.com/mugsgames

Me on Twitter [twitter]BarrySkellern[/twitter]

Thanks so much for the help! I'm glad it wasn't as difficult as I thought it'd be.

This topic is closed to new replies.

Advertisement