Global variable declared but "not declared in this scope" error

Ideally yes, the variable should be defined in the library, not the main sketch.

Even better, the variable should be entirely contained within the library and modified using function calls that the library can provide. That also gives you the ability to implement bounds checking as well.