to bark up the wrong tree

Meaning 1
When a hunting dog spots prey jumping into a tree and keeps barking at it, even though the prey has jumped to another tree.
Sentence 1
We almost caught that squirrel, but it turns out that my hound was barking up the wrong tree and it got away.
Meaning 2
to look for something where it does not exist
Sentence 2
I looked all over for my glasses, but it turns out I was barking up the wrong tree as they were already on my head.