版本:v3.13.0, 其他版本如果cmake目录结构相同,方法类似。
下载链接:protobuf: https://github.com/google/protobuf
编译方法:
cmake目录下mkdir build创建build文件
cd build
cmake ..
make
直接cmake.. 可能会报Cannot find third_party/googletest directory that's needed to build tests.错误,缺少该测试框架的依赖。
可以选择修改CMakeLists.txt不使用该功能, 把 “Build tests”置为OFF。
cmake ..成功后直接make即可编译。
如何编译动态库?
修改CMakeLists.txt打开BUILD_SHARED_LIBS选项