I have a small program where I use leptonica
.. But how can I check which version installed?
#include <leptonica/allheaders.h>
Everything is done at link-time.
If you use dynamic linking, you can specify a version of the library to be linked with, in a compiler-dependant way. For instance, see this question for how it's done with GCC.
If you use static linking, then you know which version you build against because you added the source to your project tree yourself, and you must build the library every time you build your executable.
You cannot get the leptonica version from the API.