当前位置: 首页 > news >正文

在 msys2@mingw 下编译 BVLC/Caffe

(参考 https://github.com/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 https://github.com/BVLC/caffe/archive/refs/tags/1.0.tar.gz
tar xf 1.0.tar.gz
cd caffe

Error 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"
#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()'

相关文章:

  • Java EE改Jakarta
  • 使用正则表达式批量修改函数
  • 分布式事务-Seata
  • 存在负权边的单源最短路径的原理和C++实现
  • 云原生定义整理
  • Sentinel学习(2)——sentinel的使用,引入依赖和配置 对消费者进行流控 对生产者进行熔断降级
  • 国庆10.4
  • [Spring] Spring5——AOP 简介
  • 小谈设计模式(13)—外观模式
  • 阿里云新账户什么意思?老用户、产品首购详细说明
  • 网络资料搬运(2)
  • 数据库用户管理
  • 动态规划-状态机(188. 买卖股票的最佳时机 IV)
  • 银行业务队列简单模拟(队列应用)
  • 【单片机】11-步进电机和直流电机
  • 探索ClickHouse——连接Kafka和Clickhouse
  • idea清空缓存类
  • springboot之@ImportResource:导入Spring配置文件~
  • 【数据开发】DW数仓分层设计架构与同步策略(ODS、DWD、DWS等字段含义)
  • 基于微信小程序的明星应援小程序设计与实现(源码+lw+部署文档+讲解等)
  • 对话地铁读书人|来自法学副教授的科普:读书日也是版权日
  • 美政府公布1968年罗伯特·肯尼迪遇刺事件档案
  • 信心从何而来|楼市回稳的最新迹象
  • 广州已于4月8日入夏,比常年提前8天
  • 深圳33岁男子疑因思念亡妻留绝笔殉情,亲友证实其已离世
  • 哈佛大学打响第一枪:拒绝遵守特朗普要求,22亿政府拨款遭冻结