So I have installed anaconda with python 2.7 and installed all of the requirements for Caffe library. I ensured that opencv is installed by
import cv2
I ran into the same problem and I fixed it by adding an -rpath
in my Makefile.config :
LINKFLAGS := -Wl,-rpath,$(HOME)/anaconda/lib
I think this is the correct fix because it (-rpath) tells GCC where it can find libraries (libjpeg, libpng) that other libraries (in this case opencv) depend on.
Per @cel suggestion -
ldd libopencv_highgui.so
shows the files on which this lib depends. Couple of them (not the libpng!) were located in folder which I haven't included into the makefile.config. After including their folder into MakeFile build succeeded. Notice: after building the caffe you may won't to go in Spyder into the PythonPath manager and add the caffe's folder into it (or just include it into pythonpath if you are not using anaconda\spyder).
Adding
LINKFLAGS := -Wl,-rpath,$(HOME)/anaconda/lib
in to Makefile.config worked.