Caffe installation errors I met

Error One:

Undefined symbols for architecture x86_64:
"cv::imread(cv::String const&, int)", referenced from:
caffe::WindowDataLayer<float>::InternalThreadEntry() in window_data_layer.o
caffe::WindowDataLayer<double>::InternalThreadEntry() in window_data_layer.o
caffe::ReadImageToCVMat(std::string const&, int, int, bool) in io.o
"cv::imdecode(cv::_InputArray const&, int)", referenced from:
caffe::DecodeDatumToCVMat(caffe::Datum const&, int, int, bool) in io.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Solution: https://stackoverflow.com/questions/27890137/undefined-symbols-for-architecture-x86-64-for-caffe-build

copy the following into makefile.config:

LIBRARIES += glog gflags protobuf leveldb snappy \
lmdb \
boost_system \
hdf5_hl hdf5 \
opencv_imgcodecs opencv_highgui opencv_imgproc opencv_core pthread

— — — — — —

Error Two:

CXX/LD -o python/caffe/_caffe.so python/caffe/_caffe.cpp
python/caffe/_caffe.cpp:10:10: fatal error: ‘numpy/arrayobject.h’ file not found
#include <numpy/arrayobject.h>
 ^~~~~~~~~~~~~~~~~~~~~
1 error generated.
make: *** [python/caffe/_caffe.so] Error 1

Solution: to find the numpy include and updates the makerfile.config

use this command to find the path of numpy:

import numpy as np
np.get_include()

here is the result:

/usr/local/lib/python2.7/site-packages/numpy/core/include

to change the PYTHON_INCLUDE in Makefile.config into

PYTHON_INCLUDE := /usr/include/python2.7 \
 /usr/local/lib/python2.7/site-packages/numpy/core/include

with the command vi Makefile.config under caffe root folder

— — — — — — — -

another error went like:

ld: library not found for -lboost_python
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [python/caffe/_caffe.so] Error 1

Solution: I went into the Makefile (not Makefile.config) under caffe root folder, and changes the name of boost_python

vi Makefile
:?boost_python

to find the line 👇
PYTHON_LIBRARIES ?= boost_python python2.7(before)

change into
PYTHON_LIBRARIES ?= boost_python27 python2.7(after)

then rebuild
make clean; make all; make test; make runtest; make pycaffe

before these errors, I uncommented the cpu_only=1 in makefile.config, add the python path to ~/.bash_profile and source ~/.bash_profile

Finally, done