编译
参考https://github.com/google/protobuf/blob/master/cmake/README.md
- 需要cmake, git, vs
- Native Tools Command Prompt
%comspec% /k "d:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools\VsDevCmd.bat"
- 下载https://github.com/google/protobuf/releases中的protobuf-cpp-3.5.0.zip
- 解压,cmd进入目录
E:\LIBS\Protobuf\protobuf-3.5.0E:mkdir install
- 确认环境中有cmake和bit,如果没有
If cmake command is not available from Command Prompt, add it to system PATH variable:C:\Path\to>set PATH=%PATH%;C:\Program Files (x86)\CMake\binIf git command is not available from Command Prompt, add it to system PATH variable:C:\Path\to>set PATH=%PATH%;C:\Program Files\Git\cmd
- 开始cmake,下面命令执行后会看到Makefile文件
cd cmakemkdir build & cd build;make releasemkdir release & cd releasecmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../../../../install ../..;make debug(跳回上层build目录)mkdir debug & cd debugcmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=../../../../install ../..;To create Visual Studio solution file:mkdir solution & cd solution;如果出现问题,说不存在可以用cmake --help看看是否支持。不支持高版本的vs,就要升级cmake了。;cmake -G "Visual Studio 12 2013 Win64" -DCMAKE_INSTALL_PREFIX=../../../../install ../..cmake -G "Visual Studio 15 2017 Win64" -DCMAKE_INSTALL_PREFIX=../../../../install ../..
7. 编译
打开protobuf.sln选择release还是debug,右键解决方案—->生成解决方案
- 生成INSTALL—会在最外层的install文件夹生成结果E:/LIBS/Protobuf/install
在解决方案里右键INSTALL生成
This will create the following folders under the install location:bin - that contains protobuf protoc.exe compiler;include - that contains C++ headers and protobuf *.proto files;lib - that contains linking libraries and CMake configuration files for protobuf package.
使用
cd F:\MyPrivateProjects\Git\LearnCpp\LearnProtobuf\LearnProtobufF:F:\MyPrivateProjects\Git\LearnCpp\LearnProtobuf\LearnProtobuf\google\bin\protoc.exeprotoc.exe --cpp_out=addressbook/ addressbook.proto
--cpp_out--java_out--python_out--javanano_out--php_out--ruby_out--csharp_out--objc_out--js_out
小明编程
![[转]如何解决Visual Studio调试Debug很卡很慢-小明编程](http://brightguo.com/wp-content/uploads/2016/04/20140428173726-935695682-190x150.jpg)




