Just a quick bit of helpful info for anybody that’s looking, as I lost hours of time until I figured it out:
When you compile OpenCV code, assuming you’ve got all of the links correctly set and your $PATH configured correctly, you have to use flags, and you have to use the correct syntax, like so:
g++ `pkg-config opencv --cflags` myprog.cpp -o myprog `pkg-config opencv --libs`
Note: That’s a ` mark (above the TAB key), not an apostrophe! Apparently, that makes all the difference.