Environment : Mac OS 10.9 + Qt5.1/Qt5.2 + OpenCV2.4.7 + XCode(5.0.2)
I can compile the following program via terminal
g++ -L/usr/local/lib -lopencv_
The problem is not with the system. On Mac you just have to include imgcodecs header and include the respective lib files also. This will solve all the trouble you had.
-lopencv_imgcodecs