It really should be saved in a .mod file. All data types and function prototypes are stored there, so you need to enable it when you send someone a .lib file. Try connecting in the module after using it in something else, and it should work fine.
Essentially, a .mod file performs the same task as a .h file in c, so of course you have to include it in your library.
[Update:] If you are trying to use this in C, then, as you said, there is no way to simplify saving a named constant. Alternatively, you can use the protected attribute for the object. At least with Fortran, everything outside the module is limited to writing to a variable. I don't know if the C compiler and linker will respect this behavior, but I think this is probably your best shot.
module testMOD INTEGER, PROTECTED, BIND(C) :: globalvar = 1 end module testMOD
Unfortunately, I don't understand much about interoperability with C, so I cannot guarantee that C will respect the protected attribute and will not allow the variable to be changed.
source share