This is not how RSA works, and not how public-key cryptography
works. The key is never an arbitrary piece of data. Even if it was so, isn't the following obvious: if one key is arbitrary, the second of the keys in the key pair is somehow related to the other key? :-)
First of all, you really need to understand how public-key cryptography works. Please see:
] (very clear explanation, must-read for every developer),
As to Crypto++ implementation, the documentation is quite easy to find:
The final note: if you say that this simple problem "cost me too much time", this is troublesome sign, but all you need it to keep learning and getting experience. All such problems should be resolved quickly, as they are reduced to just using some very usual API, not creating something new.