手动编译protobuf3的C++源码

Windows下编译

官方文档
第三方文档html

准备工具

须要注意

推荐按照第三方的文档上的安装就能够了,可是中间会有许多坑。
好比:如果下载proto3的最新版,就会编译错误,我这里也没找到为嘛错误,因此就按照第三方文档上面的git 3.0版本的源代码。git

按照各自的需求修改源代码后,直接进行编译和检查就好了。github

主要步骤

一、 经过你的开始菜单,打开Visual Studio 2013的开发人员命令提示工具:

二、而后cd到D盘,本身建立如下目录工具

  1. D:\Path\to

三、git源代码(3.0版本)ui

  1. D:\Path\to>git clone -b v3.0.0 https://github.com/google/protobuf.git
  2. D:\Path\to>cd protobuf
  3. D:\Path\to\protobuf>
  4. D:\Path\to\protobuf>git clone -b release-1.7.0 https://github.com/google/googlemock.git gmock
  5. D:\Path\to\protobuf>cd gmock
  6. D:\Path\to\protobuf\gmock>git clone -b release-1.7.0 https://github.com/google/googletest.git gtest

四、cmake的配置google

  1. D:\Path\to\protobuf\gmock>cd ..\cmake
  2. D:\Path\to\protobuf\cmake>

五、建立build临时编译目录spa

  1. D:\Path\to\protobuf\cmake>mkdir build & cd build
  2. D:\Path\to\protobuf\cmake\build>

六、Release 配置code

  1. D:\Path\to\protobuf\cmake\build>mkdir release & cd release
  2. D:\Path\to\protobuf\cmake\build\release>cmake -G "NMake Makefiles"-DCMAKE_BUILD_TYPE=Release-DCMAKE_INSTALL_PREFIX=../../../../install ../..

七、开始编译发布htm

  1. D:\Path\to\protobuf\cmake\build\release>nmake

接下来等待一段时间:

八、获取编译后的可执行文件
在当前文件夹下,就能够看到编译好的文件:protoc.exe blog

相关文章
相关标签/搜索