Ill do my best to effort post on this throw away topic, about something that is both impossible to answer while also being one of the most important to try.
Been reading alot of Ceneca's letters lately, so my feelings lean in towards the more Stoic route of thinking, but I think he to some extent has some thoughts the drive further into an almost zen balance argument, for lack of a better term; what I mean to say is, its not all or nothing, to be happy, to not be happy, but its as simple as that.
"Not happy he who thinks himself not so"
What I mean to say is that, its not about having enough to be, whether thats friends or things or attainment of some title; you can always have alot relative to other people, but simply believe it isnt enough. Alot of our unhappiness comes from our perceived lack of something we dont really need. So my advice to the unhappy is to be happy, and not in some cynically self denying sense that you should stop seeking to attain things all together, but to appreciate and enjoy what you already have while building on yourself.
I think the more difficult subject is how happiness is something of an island, you cant control other people or own them or hold them forever, they're themselves another person seeking to attain their own happiness, and in that, you cant depend on them for yours, so to me it seems like happiness and loneliness are similar; they're from the same fruit, both the bitter and sweet notes of a gift... but in the interpretations Ive been reading, its more complicated than that; to be content with yourself, but to love openly and deeply, for those you truly vet.
"I shall show you, a love philtre compounded without drug or herb or witch's spell. It is this: if you wish to be loved, love."
These are less complete ideas in my mind, but to lay some foundation, typically of the people you love, you have reasons to love them, something like what they can offer you, and what you can offer them, and in that, your relationships become transactional and youre kept around as long as you remain useful; you build alot of fair weather friends, but the stuff Ive been reading argues for something different. To truly love someone, to find a true friend, is to find someone who can really understand you, be a peer that you can both guide and get guidance from, and commit fully; be there even if theres nothing for you to gain, and try to share the wisdom you can, that person will be there for you always. I struggle with this, since I see relationships as transactional most of the time, and often Im treated in a similar fashion...
But no more rambling. In a nutshell, to be happy is to be happy with what you have, while working to better yourself now, not for the attainment of what could be. to be loved is to love, not in the pursuit of gaining something from that love, but to have something to commit to and grow, so that it can bear fruit into the future.