【问题 & 解决】编译 Protobuf 和 TNN 模型时遇到的问题

因为要研究TNN如何做模型转换,因此需要编译TNN源码中的tools/onnx2tnn模块。

编译过程中,遇到一个问题:

error: no match for 'operator[]' (operand types are 'const google::protobuf::RepeatedField<long int>' and 'int')

从错误信息中可以看到,问题出在 protobuf 上,类 RepeatedField 没有对 [] 运算符进行重载。经过 Google 后,发现是 Protobuf 版本太老的问题。备注:我的系统是 Ubuntu 18.04,通过 apt 安装的 Protobuf,默认版本是 3.0.0.
因此需要安装更新版本的 Protobuf,采取的策略是源码安装。

参照 https://blog.csdn.net/Awesomewan/article/details/106207763

完成 Protobuf 的安装,再次编译 TNN 中的tools/onnx2tnn模块,成功编译。

posted @ 2022-03-01 16:35  虔诚的树  阅读(487)  评论(0编辑  收藏  举报