including libraries

Really stupid question: how do I include libraries I made myself?
I just made a static library with a word-wrapping function in, takes in a string and makes the text wrap round for a given width. I know how to include libraries like iostream and stuff but I have no idea about my own libraries.
Also I can't find any info about this anywhere, is it so simple that nobody even needs to write about it normally?
If you're talking about ".lib" files, then:

Include the header file which contains the function prototype for your word-wrapping function.

void MyWordWrapper(parameters);

And in that header file add:

#pragma comment(lib, "myLib.lib")
I was under the impression that #pragma is considered evil around here, which is why I didn't list it.

-Albatross
Sorry to be really stupid, but this is just how basic I need to go. I understand that you need a copy of a static library (the one with the .lib extension) somewhere in your project folders (I'm using VC++ 2008). Where exactly do I need to put a copy of it? And then can I just put:
 
#include "mystringlib.h" 

in my source file for the project that wants to include it or do I need to include the pragma line in the actual library as well?
Thanks again, and sorry for being dumb.
@ Albatross: In all honesty I don't know why that #pragma command would be considered "evil". Maybe there are other pragma commands which go against "programming etiquette", I don't know.

@ James: Add the #pragma command in to "mystringlib.h". Using the pragma command is essentially the same as including a header file. Actually, that's exactly what it's doing.
The problem with pragma is that it is HIGHLY compiler dependent, so #pragma dostuff could do completely random things on different compilers. The only #pragma I use is once, and even then I wrap it in #ifdefs for the compiler I am currently using.
Where in my project folders do I need to put a copy of the .lib file? I do need to do this right?
What compiler and/or IDE are you using?


EDIT: If it's a closed source project, and the project is all done with the same compiler, then there is no reason why a #pragma directive should be considered evil. If I'm working on something open source I'll use #ifdef arround my #pragma, and only use #pragma when necessary. But if it's something I alone am working on, or am working on for school in a group, then #pragma away :P
Last edited on
Topic archived. No new replies allowed.