When the private key is compromised, there are several things you need to do:
Stop using the private key (obviously): since other parties can now impersonate you using the leaked key, you should forfeit the key altogether.
Inform other parties (i.e. all your customers and users of your library) that the key was compromised: they should stop using the corresponding public key. How you do so depends on how you propagated the public key in the first place. If you used a KDC (Key Distribution Center) of any form, you should notify it of the leak and possibly revoke it if it lets you.
Generate a new pair and distribute the replacement public key to your correspondents and/or the KDC.
From your question, you seem to have a key distribution problem: you give the impression that your public key is distributed as an embed inside your library, so you can't easily prevent the usage of a compromised key's public part by your customers (apart from telling them to stop using your library, which is most probably a no-no).
If your question is pre-empting any leak (hopefully), you should redesign your library to acquire the relevant public key separately from being hardcoded. A simple scheme goes along these lines:
You may distribute the public key as a file (e.g. signed X.509 certificate) inside your library's installer. The installer should be responsible for installing the file as well as the library inside the guest OS and configure the library to use it.
You may distribute standalone installers for a public key file and similarly have it install (replace) the file inside the guest OS and configure the library to use it.
That way, in the event of a leak, your customers can receive a single, non-functional patch, which is usually much easier (much less risk to production) to get through approval than a full reinstall.
If you have the luxury to use a KDC, have your library periodically verify it uses the currently valid public key at disposal. KDCs usually are able to tell clients that the key they are using is valid or revoked, and also expose the currently valid one.
Remember that by having your private key leaked, you will suffer a hit on your customers' trust. Being able to swiftly and efficiently correct the situation will be paramount in keeping you on their good side.