trying to make a library "multiple definition of '#var'

WizenedEE:
You cannot do anything in a .h file that allocates memory -- essentially, you may declare functions (but not define them), declare data as extern (but not as non-extern) and declare classes (and structs and enums and unions...)

okay:

// foo.h

extern int bar;
void f();
class foobar {
public:
  foo();
};




not okay:


int var;
void func() {
  var++;
}




Note that if a variable is declared extern, it must be defined somewhere else. "extern" means "the variable is defined somewhere else" so you'll just confuse the linker if you say it's somewhere else and then not have it at all. This also means you can't give a value to them because that's a definition, not a declaration.

Thank you very much for this information, it worked perfectly!

I have just one more question regarding libraries :
Is it possible to just give compile it and send it to my friends in order to avoid them looking in the source (cpp) ?

Like a folder in Libraries with a File.h and File.o instead of File.cpp?