在msys2@mingw下编译BVLC/Caffe
- 互联网
- 2025-08-18 00:54:03

(参考 github /lemonsqueeze/mingw-caffe )
有关需要安装的工具,上面这篇已经说的很明白了,照搬于下。
pacman -S git make patch diffutils # 32-bit build: pacman -S mingw32/mingw-w64-i686-tools-git # gendef, dlltool pacman -S mingw32/mingw-w64-i686-gcc pacman -S mingw32/mingw-w64-i686-boost pacman -S mingw32/mingw-w64-i686-protobuf-c pacman -S mingw32/mingw-w64-i686-gflags pacman -S mingw32/mingw-w64-i686-glog pacman -S mingw32/mingw-w64-i686-hdf5 pacman -S mingw32/mingw-w64-i686-openblas # 64-bit build: pacman -S mingw64/mingw-w64-x86_64-tools-git # gendef, dlltool pacman -S mingw64/mingw-w64-x86_64-gcc pacman -S mingw64/mingw-w64-x86_64-boost pacman -S mingw64/mingw-w64-x86_64-protobuf-c pacman -S mingw64/mingw-w64-x86_64-gflags pacman -S mingw64/mingw-w64-x86_64-glog pacman -S mingw64/mingw-w64-x86_64-hdf5 pacman -S mingw64/mingw-w64-x86_64-openblas还要下载 caffe 源代码
wget github /BVLC/caffe/archive/refs/tags/1.0.tar.gz tar xf 1.0.tar.gz cd caffeError 1:
/home/rd/NN/caffe/src/caffe/layers/window_data_layer.cpp: In member function ‘virtual void caffe::WindowDataLayer<Dtype>::load_batch(caffe::Batch<Dtype>*)’: /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" #endifError 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 github /onnx/onnx/issues/2678
Solution :
#if GOOGLE_PROTOBUF_VERSION >= 3002000 coded_input->SetTotalBytesLimit(kProtoReadBytesLimit); #else coded_input->SetTotalBytesLimit(kProtoReadBytesLimit, 536870912); #endifError 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 github /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 installError 4:
/usr/bin/ld: common.cc:(.text+0x29e): undefined reference to `absl::lts_20230125::log_internal::LogMessageFatal::~LogMessageFatal()'
在msys2@mingw下编译BVLC/Caffe由讯客互联互联网栏目发布,感谢您对讯客互联的认可,以及对我们原创作品以及文章的青睐,非常欢迎各位朋友分享到个人网站或者朋友圈,但转载请说明文章出处“在msys2@mingw下编译BVLC/Caffe”
下一篇
数据库用户管理