Let's review. What you are trying to express is:
John lost his friend. John was crying for his friend.
Of course, such repetition is undesirable, so English has a tool you can use, called a relative-pronoun. Relative pronouns include who, whom, that, and which. Of those choices, who and whom can be used to refer to people. Who is used for subjects; whom is used for objects.
You probably know all that already, but just need advice in applying the rules.
The pronoun you want is the one in the objective case (whom), because John lost his friend. (Using the subjective case pronoun who would mean that the friend lost John, which is not what you want.)
Remember, also, that relative pronouns help you refer to a noun that would otherwise be repeated. Relative pronouns don't stand alone. The correct sentence should be:
John was crying for the friend whom he lost.
That said, even native English speakers often fail to distinguish between subjective and objective cases correctly. Therefore, you have to be careful about parroting patterns that you see and hear, as you may be copying incorrect examples. On the other hand, you are also unlikely to be stigmatized for choosing the wrong case in everyday speech.
This sentence is already extremely stiff and formal sounding:
It ought to be him with whom you share your secrets, not me.
You can replace me with I without a change in meaning, but it becomes even more formal and even less natural:
It ought to be him with whom you share your secrets, not I.
In natural speech, people are far more likely to use not me. Of course, since your sentence is already hyper-formal, you might actually prefer to use the unnatural not I.
But if you'd like to use natural English, you could say something like this (depending on context):
You should tell him, not me.
Simple and to the point.
Best Answer
As has been said in the comments, languages are constantly undergoing transformation. In cases like this, I like to use Google Ngrams. You can basically search a database of books written after 1900 for specific expressions and their frequency of use.
Link to Ngrams page
As you can see, "by him who" is vastly more popular, so I suggest using that, as @apsillers already stated in a comment.