compile BVLC/Caffe

Found Error when compile Caffe

Error 1:

/home/rd/NN/caffe/src/caffe/layers/window_data_layer.cpp: In member function ‘virtual void caffe::WindowDataLayer::load_batch(caffe::Batch*)’:
/home/rd/NN/caffe/src/caffe/layers/window_data_layer.cpp:293:42: error: ‘CV_LOAD_IMAGE_COLOR’ was not declared in this scope
  293 |         cv_img = cv::imread(image.first, CV_LOAD_IMAGE_COLOR);
      |                                          ^~~~~~~~~~~~~~~~~~~
make[2]: *** [src/caffe/CMakeFiles/caffe.dir/build.make:1090:src/caffe/CMakeFiles/caffe.dir/layers/window_data_layer.cpp.o] 错误 1
make[1]: *** [CMakeFiles/Makefile2:400:src/caffe/CMakeFiles/caffe.dir/all] 错误 2

Root Cause : codes for opencv2 or opencv3 are not compatiable to opencv4, so add below codes

Solution :

#if (CV_MAJOR_VERSION > 3)
#include "opencv2/imgcodecs/legacy/constants_c.h"
#endif

Error 2:

home/rd/NN/caffe/src/caffe/util/io.cpp: In function ‘bool caffe::ReadProtoFromBinaryFile(const char*, google::protobuf::Message*)’:
/home/rd/NN/caffe/src/caffe/util/io.cpp:60:66: error: no matching function for call to ‘google::protobuf::io::CodedInputStream::SetTotalBytesLimit(const int&, int)’
   60 |   coded_input->SetTotalBytesLimit(kProtoReadBytesLimit, 536870912);

Root Cause : refer to https://github.com/onnx/onnx/issues/2678

Solution :

#if GOOGLE_PROTOBUF_VERSION >= 3002000
    coded_input->SetTotalBytesLimit(kProtoReadBytesLimit);
#else
    coded_input->SetTotalBytesLimit(kProtoReadBytesLimit, 536870912);
#endif

Error 3:

/usr/local/lib/libgflags.a(gflags.cc.o): relocation R_X86_64_PC32 against symbol `stderr@@GLIBC_2.2.5' can not be used when making a shared object;

Root Cause:

refer to https://github.com/BVLC/caffe/issues/2171,   2016-08-26/2022-06-21

Solution :

libgflags library is not built as shared. You may recompile it with below commands

cd build/
cmake .. -DBUILD_SHARED_LIBS=ON
make
sudo make  install

Error 4:

/usr/bin/ld: common.cc:(.text+0x29e): undefined reference to `absl::lts_20230125::log_internal::LogMessageFatal::~LogMessageFatal()'

你可能感兴趣的:(caffe,人工智能,深度学习)