1. 下载protobuf-3.6.1源码:https://github.com/protocolbuffers/protobuf/releases
2.下载cmake windows工具(并将bin目录加入到path):https://cmake.org/download/
3. 打开cmd工具进入protobuf-3.6.1目录:
mkdir install
cd cmake
mkdir build & cd build
cmake -G "Visual Studio 15 2017" -DCMAKE_INSTALL_PREFIX=../../../../install -Dprotobuf_BUILD_TESTS=OFF ../..


打开生成的工程。分别使用debug/release方式编译安装

右键ALL_BUILD选择编译

右键选择INSTALL选择编译(实际为安装)
在protobuf-3.6.1上层目录,生成install目录文件,

bin: protoc.exe
include: 头文件
lib: 生成的静态库
debug的库:

release的库:

到这里,已经编译完成,下一节,简单使用protobuf.
https://blog.youkuaiyun.com/shan165310175/article/details/86624591
附加: 忽略警告:
- C4018 - 'expression' : signed/unsigned mismatch
- C4146 - unary minus operator applied to unsigned type, result still unsigned
- C4244 - Conversion from 'type1' to 'type2', possible loss of data.
- C4251 - 'identifier' : class 'type' needs to have dll-interface to be used by clients of class 'type2'
- C4267 - Conversion from 'size_t' to 'type', possible loss of data.
- C4305 - 'identifier' : truncation from 'type1' to 'type2'
- C4355 - 'this' : used in base member initializer list
- C4800 - 'type' : forcing value to bool 'true' or 'false' (performance warning)
- C4996 - 'function': was declared deprecated
本文详细介绍了如何从源码编译 Protobuf 3.6.1 版本,包括下载源码、配置 CMake、使用 Visual Studio 进行 Debug 和 Release 编译,以及如何处理常见警告信息。
4308

被折叠的 条评论
为什么被折叠?



