Not everything should be class. The Singleton template would allow you to turn this into a class, but it really didn't buy you anything in terms of global functions:
bool my_library_init(); void my_library_shutdown();
The first call returns true if the library was successfully initialized, the second simply silently does everything that needs to be done and exits. You can add any counting links or type of thread tracking for these interfaces that you like.
Also, do not neglect the possibility that your library can do all this transparently. When the first library function is called, can it detect that it has not yet been initialized and is not configured before the job is done? To shutdown, simply register the resources that you want to destroy using the global object, so they will be destroyed when you exit the program. Performing this method is, of course, more complicated, but it can be useful for library users.
Warren young
source share