GRPC for windows - Visual Studio .props file
Git for windows CMake
Clone grpc from https://github.com/plasticbox/grpc-windows
git clone https://github.com/plasticbox/grpc-windows
Run grpc_clone.bat Run grpc_build.bat
Note: setting up proxy before running grpc_clone.bat (Chinese users: This might be the solution you are finding)
For example, if you run a local proxy server at port 1080
git config --global http.proxy 127.0.0.1:1080
Clone grpc from https://github.com/grpc/grpc.git
git clone https://github.com/grpc/grpc.gitUpdate submodules (IMPORTANT)
git submodule updateCopy grpc folder to
grpc-windows
(so thatgrpc_clone.bat
won't download again.) Rungrpc_build.bat
#####Installing protobuf
Download
protobuf
from: https://github.com/google/protobuf/releases (Note: if you want to use it together with a pre-installed protoc, make sure to match the versions)mkdir .build cd .build cmake -G "Visual Studio 14 2015 Win64" ../cmake/Open Visual Studio solution and build. Targets are in
.build/[Debug|Release]/
Try to use predefined .props
files and packages.config
file~
It seems you have to manually add NuGet packages by right click project - Manage NuGet packages
. Simply adding packages.config
to project does not seem to work. (because package dependencies are defined in .vcxproj
file)
In summary:
- Add
grpc_debug.props
andgrpc_release.props
viaProperty Manager
- Change the macro
$(GRPC_HOME)
in those.props
if needed - Add
grpc.dependencies.*
packages in NuGet package manager (Actually addinggrpc.dependencies.openssl
is enough, the others are dependencies of openssl) - Edit
Build events
-Pre-build events
-Command
if needed. The default command executes protoc for each .proto file under project directory - Build and enjoy~
$(GRPC_HOME) = dir\to\grpc-windows\grpc
Add it to User Macros
under Property Manager
is a good idea.
INCLUDE PATH:
$(GRPC_HOME)\third_party\protobuf\src
$(GRPC_HOME)\include
LIBRARY PATH:
$(GRPC_HOME)\bin\protobuf\release
$(GRPC_HOME)\bin\grpc\release
LINKED LIBRARIES:
libprotobuf.lib
gpr.lib
grpc.lib
grpc++.lib
ws2_32.lib
NuGet Packages:
grpc.dependencies.openssl
grpc.dependencies.openssl.redist
grpc.dependencies.zlib
grpc.dependencies.zlib.redist
//grpc.dependencies.openssl.symbols
//grpc.dependencies.zlib.symbols
NOTE:
- Set
C/C++
-Code Generation
-Runtime Library
to/MT
- Add
_WIN32_WINNT=0x600
(or higher) toC/C++
-Preprocessor
-Preprocessor Definitions
- Add to
Build events
-Pre-build events
-Command
something like
for %%f in (*.proto) do (
$(GRPC_HOME)\bin\protobuf\release\protoc.exe -I . --grpc_out=. --plugin=protoc-gen-grpc=$GRPC_HOME$\bin\grpc_protoc_plugins\grpc_cpp_plugin.exe %%f
$(GRPC_HOME)\bin\protobuf\release\protoc.exe -I . --cpp_out=. %%f
)