手動編譯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

相關文章
相關標籤/搜索