其实网上文章已经很多了,这里只写流程和注意事项。
一、源码
git clone https://github.com/protocolbuffers/protobuf.git
二、选择合适的版本
git checkout v3.8.0
三、其他组件
git submodule update --init --recursive
四、source交叉编译环境变量
五、修改cmake,取消编译test,如果打开,会在编译期间运行protoc工具生成h和cc,由于交叉编译的protoc只能在arm上运行,所以会报错。
六、开始编译,注意自定义一下install路径
cmake -DCMAKE_INSTALL_PREFIX=install ../cmake
make -j12 install