Requirements/Best Practice for gRPC with c++ on Windows

2,964 views
Skip to first unread message

horst....@crossbody.de

unread,
Mar 21, 2016, 3:05:33 PM3/21/16
to grpc.io
I tried to get the samples to run with mingw. The older versions did not have a definition for CONDITION_VARIABLE at all in the header files and even the headerfiles from version 5.3.0 where the CONDITION_VARABLE exists in syncapi.h did not compile without errors...
..but I would like to work with gRPC on Windows connecting to a golang application on Linux. So i would like to know which c++ compilers and versions can do the job without pain.

Nicolas Noble

unread,
Mar 21, 2016, 3:09:33 PM3/21/16
to horst....@crossbody.de, grpc.io

I would recommend using visual studio 2013 or 2015 since this is our main development targets under windows. If you really want to use gcc, try msys2.


On Mon, Mar 21, 2016, 12:05 <horst....@crossbody.de> wrote:
I tried to get the samples to run with mingw. The older versions did not have a definition for CONDITION_VARIABLE at all in the header files and even the headerfiles from version 5.3.0 where the CONDITION_VARABLE exists in syncapi.h did not compile without errors...
..but I would like to work with gRPC on Windows connecting to a golang application on Linux. So i would like to know which c++ compilers and versions can do the job without pain.

--
You received this message because you are subscribed to the Google Groups "grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+u...@googlegroups.com.
To post to this group, send email to grp...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/6540e43a-5da5-4615-a558-7f5c32d9e66d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

horst....@crossbody.de

unread,
Mar 22, 2016, 8:58:07 AM3/22/16
to grpc.io, horst....@crossbody.de
Thanks for your fast reply! With visual studio 2015 I could build some libraries and a grpc_cpp_plugin.exe. But it seems that i need a protoc-gen-grpc.exe as a plugin for protoc. Is the protoc-gen-grpc.exe part of the grpc c++ package and i can't see it or does it belong to another (language) package..

GoldenBull Chen

unread,
Mar 22, 2016, 11:11:02 AM3/22/16
to horst....@crossbody.de, grpc.io
Here is the script I write to build grpc using VS2015 on windows. You can change the first several lines to your own directory. Don't forget to install cmake and init sub modules before building.
Also note that the last step building x64 grpc lib will fail because of a protobuf bug.
=====================
@set nuget=%~dp0..\..\..\nuget\nuget.exe
@pushd ..\..\..\..\grpc
@call "%VS140COMNTOOLS%\vsvars32.bat"

@rem --------------------------------------------------------------------------------------
@title build protobuf to generate protoc.exe
pushd third_party\protobuf\cmake
cmake -G "Visual Studio 14 2015" -Dprotobuf_BUILD_TESTS=OFF . || goto :error
@rem for x64: cmake -G "Visual Studio 14 2015" -A "x64" -Dprotobuf_BUILD_TESTS=OFF . || goto :error
msbuild protobuf.sln /p:Configuration=Release /m || goto :error
msbuild protobuf.sln /p:Configuration=Debug /m || goto :error
popd

@rem --------------------------------------------------------------------------------------
@title build C# protobuf lib
pushd third_party\protobuf\csharp\src
%nuget% restore Google.Protobuf.sln || goto :error
msbuild Google.Protobuf.sln /p:Configuration=Debug /m || goto :error
msbuild Google.Protobuf.sln /p:Configuration=Release /m || goto :error
popd

@rem --------------------------------------------------------------------------------------
@title build grpc plugins for protoc.exe
pushd vsprojects
%nuget% restore grpc_protoc_plugins.sln || goto :error
msbuild grpc_protoc_plugins.sln /p:Configuration=Release /m || goto :error
popd

@rem --------------------------------------------------------------------------------------
@title build grpc C# extension x86
pushd vsprojects
%nuget% restore grpc_csharp_ext.sln || goto :error
msbuild grpc_csharp_ext.sln /t:grpc_csharp_ext /p:Configuration=Debug;Platform=Win32 /m || goto :error
msbuild grpc_csharp_ext.sln /t:grpc_csharp_ext /p:Configuration=Release;Platform=Win32 /m || goto :error
@title build grpc C# extension x64
msbuild grpc_csharp_ext.sln /t:grpc_csharp_ext /p:Configuration=Debug;Platform=x64 /m || goto :error
msbuild grpc_csharp_ext.sln /t:grpc_csharp_ext /p:Configuration=Release;Platform=x64 /m || goto :error
popd

@rem --------------------------------------------------------------------------------------
@title build grpc C# lib
pushd src\csharp
%nuget% restore Grpc.sln || goto :error
msbuild Grpc.sln /p:Configuration=Debug /m || goto :error
msbuild Grpc.sln /p:Configuration=Release /m || goto :error
popd

@rem --------------------------------------------------------------------------------------
@title build grpc lib
pushd vsprojects
%nuget% restore grpc.sln || goto :error
msbuild grpc.sln /p:Configuration=Debug;Platform=Win32 /t:grpc++ /m || goto :error
msbuild grpc.sln /p:Configuration=Release;Platform=Win32 /t:grpc++ /m || goto :error
msbuild grpc.sln /p:Configuration=Debug;Platform=x64 /t:grpc++ /m || goto :error
msbuild grpc.sln /p:Configuration=Release;Platform=x64 /t:grpc++ /m || goto :error
popd

@echo *************** Success! ***************
@goto :end

:error
@echo *************** Failed! ***************

:end
popd
pause
===========================================================

2016-03-22 20:58 GMT+08:00 <horst....@crossbody.de>:
Thanks for your fast reply! With visual studio 2015 I could build some libraries and a grpc_cpp_plugin.exe. But it seems that i need a protoc-gen-grpc.exe as a plugin for protoc. Is the protoc-gen-grpc.exe part of the grpc c++ package and i can't see it or does it belong to another (language) package..

--
You received this message because you are subscribed to the Google Groups "grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+u...@googlegroups.com.
To post to this group, send email to grp...@googlegroups.com.

Shushan Chai

unread,
Mar 22, 2016, 9:30:33 PM3/22/16
to grpc.io, horst....@crossbody.de
Build GRPC with CMake on Windows/OSX:

https://github.com/chai2010/grpc-windows


在 2016年3月22日星期二 UTC+8上午3:05:33,horst....@crossbody.de写道:

horst....@crossbody.de

unread,
Mar 23, 2016, 6:53:14 AM3/23/16
to grpc.io, horst....@crossbody.de
Many Thanks! I used your project to build protobuf and gprc in one step. 
The process twice stopped, the include files for openssl and the library files for open ssl where not assigned in the /grpc-windows/grpc/CMakeLists.txt


if(WIN32)
include_directories(AFTER ${CMAKE_SOURCE_DIR}/3rdparty/openssl/openssl-win32/include)
link_directories(AFTER ${CMAKE_SOURCE_DIR}/3rdparty/openssl/openssl-win32/lib)
else()
include_directories(AFTER ${CMAKE_SOURCE_DIR}/3rdparty/openssl/openssl-win64/include)
link_directories(AFTER ${CMAKE_SOURCE_DIR}/3rdparty/openssl/openssl-win64/lib)
endif()

I inserted these lines and then it worked well and created all the libs and exe-files.


Now I think my problem is differernt. May be a missing link in the understanding of the gprc workflow.
I have the protoc.exe and the gprc_cpp_plugin.exe in the same directory (with a protoc-gen-go.exe)

When I follow the Instructions for the usage of protoc on https://github.com/grpc/grpc/blob/release-0_13/examples/cpp/cpptutorial.md 
protoc --grpc_out=. --plugin=protoc-gen-grpc=`which grpc_cpp_plugin` route_guide.proto
[I am in the directory ../protos, so i reduced the command from the example]

With this command I got an error:  grpc_cpp_plugin: no such file or directory


For golang ( --go_out=. )  I just copied the protoc-gen-go.exe file in the same directory, where the protoc.exe resists.

Now i am confused how to deal with grpc_cpp_plugin.exe.

horst....@crossbody.de

unread,
Mar 23, 2016, 7:59:02 AM3/23/16
to grpc.io, horst....@crossbody.de
[SOLVED]

I found a hint in the makefile, where the usage for the plugin parameter is different

protoc --grpc_out=. --plugin=protoc-gen-grpc=../../bin/grpc_cpp_plugin.exe helloworld.proto

with a concrete path for protoc-gen-grpc=[PATH] it works.

The syntax from the upper example failed. I think i would be a good idea for protoc to scan the homedirectory for plugins...  

Reply all
Reply to author
Forward
0 new messages