The point in Ecclesiastes is that nothing in the world itself is the source of meaning. If you come up with something, it is meaningless. Riches? Vanity. Fame? Vanity. All of it fades. Essentially he believes this because of mortality.
But of course, mortality too is vain and meaningless. The author arrives at the only sensible conclusion:
"So I recommend having fun, because there is nothing better for people in this world than to eat, drink, and enjoy life. That way they will experience some happiness along with all the hard work God gives them under the sun."
Of course this too is "vanity" but what you see in this conclusion, and in the conclusion of the book, is that if everything is meaningless, then it's also true that nothing is. It never says this explicitly I grant you, but it is the only basis for what recommendations the author does make: to simply enjoy life while it lasts, and in the book's words "honor your creator," which means to appreciate the miracle of your own being.
Because, yes, everything is meaningless, yet, everything *is*. And it is all the same as well. Under the premise that "everything is meaningless," we are free to construe meaning, which the author himself does. The most meaning you can construct is simply along the lines of "honor your creator" or put more basically, "appreciate life." You don't have to, but the point is, it doesn't make any sense not to. And so by showing that no single thing inside the universe is the source of meaning, the author then shows that meaning is only to found everywhere, or nowhere.
If you go back and read the depressing parts at the beginning about mortality with the advice in mind to appreciate that you exist at all, no matter for how long, you see that "generations come and generations go, but the earth never changes" is not so much "wearisome" but is actually a comfort. The earth never changes, and never has, yes. this is something to be in awe of, not something to lament. Why? We are a part of the earth. Generations come and generations go. That's us, our role in it. So, I recommend having fun.