C++網路程式設計(一)gRPC的編譯
Google是真滴煩,整個編譯鏈全是自家產品,在編譯之前先來安裝一堆東西
安裝環境依賴
- chocolatey Windows下的包管理系統,沒有他就慢慢去下載下面的一堆亂七八糟的東西吧。CMD下執行下面這句話就可以安裝了。
@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
- Git
- Visual Studio 2015 or 2017 這個你懂的.
- CMake.
- Active State Perl (choco install activeperl) - perl會被gRPC的第三方依賴 boringssl 使用到
- Go (choco install golang) - 會被gRPC的第三方依賴 boringssl 使用到(我只是個C++強行給我裝上了GO)
- yasm and add it to PATH (choco install yasm) - 也會被gRPC的第三方依賴 boringssl 使用到(麻煩死了)
- 可選Ninja (choco install ninja)
下載原始碼依賴
如果你裝了chocolatey,你就可以用括號裡的choco命令來安裝東西了 還沒完,上面只是環境依賴,接下來下載原始碼依賴。
把依賴分別解壓到grpc-1.20.0\third_party\對應的依賴包下面去
1.c-cares 解壓到grpc-1.20.0\third_party\cares\cares
2. boringssl解壓到grpc-1.20.0\third_party\boringssl
3. gflags解壓到grpc-1.20.0\third_party\gflags
4. zlib解壓到grpc-1.20.0\third_party\zlib
5. benchmark解壓到grpc-1.20.0\third_party\benchmark
完成上面的事情後輸入CMD指令:
md .build
cd .build
新建編譯資料夾然後cd進去,接下來編譯
我的編譯器是Visual Studio 15 2017,所以指定編譯器是Visual Studio 15 2017,如果是2015,則是Visual Studio 14 2015
cmake .. -G "Visual Studio 15 2017"
最後,編譯Release版本,如果不加Release則預設為Debug版本
cmake --build . --config Release
結果。。。。。。。。。
編譯了21分鐘不說。。。。。還報錯了。。驚了
既然知道在grpc-1.20.0\third_party\boringssl\tool\transport_common.cc(19)這個地方,找過去。
微軟是這麼說的
呼叫 c + + 標準庫中的任何潛在的不安全的方法會導致編譯器警告 (等級 3) C4996。 若要禁用此警告,請在程式碼中定義巨集 _SCL_SECURE_NO_WARNINGS:
好了bb這麼多直接註釋掉就好了。。。。。。
再來一次build all