I have been following the grpc-web helloworld example but am stuck when trying to build the protoc-gen-grpc-web plugin on my Mac. Here's what happens:
nmurthy:grpc-web% sudo make install-plugin
cd "/Users/nmurthy/Workspace/grpc-web"/javascript/net/grpc/web && make install
g++ grpc_generator.o -L/usr/local/lib -lprotoc -lprotobuf -lpthread -ldl -o protoc-gen-grpc-web
ld: library not found for -lprotoc
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [protoc-gen-grpc-web] Error 1
make: *** [install-plugin] Error 2
Wondering how do I properly link this library?
(Cross posted here: https://groups.google.com/forum/#!topic/grpc-io/kcIZb6N_Lhg)
Here's my setup:
nmurthy:grpc-web% protoc --version
libprotoc 3.6.1
nmurthy:grpc-web% which protoc
/Users/nmurthy/Tools/protoc-3.6.1-osx-x86_64/bin/protoc
md5-b450294185df5b64576ab4db8a6d0b8c
nmurthy:grpc-web% ls -l ~/Tools/protoc-3.6.1-osx-x86_64/include/google
total 0
drwxr-xr-x 184 nmurthy staff 6256 Nov 7 15:12 protobuf
Related #342
Oh I see, you have the protoc binary, but not the protoc library that we can link with -lprotoc.
This is not good user experience, but you will have to manually compile and install the protoc library for now.
In the helloworld example README, here's the instructions on how to compile and install protoc:
$ ./scripts/init_submodules.sh
$ cd third_party/grpc/third_party/protobuf
$ ./autogen.sh && ./configure && make -j8
$ sudo make install
We will be providing pre-compiled binaries for the protoc-gen-grpc-web plugin across a few platforms shortly in the future.
Thanks @stanley-cheung, that was my assessment after reading #342 . Any tips or "gotchas" I should be aware of to ensure my existing protoc binary and libraries do not interfere with this manual installation?
As a related matter, I also tried npm installing this from https://www.npmjs.com/package/@grpc-gen/protoc-gen-grpc-web but observed that it is currently not supported on macOS.
nmurthy:grpc-web% npm i @grpc-gen/protoc-gen-grpc-web
npm ERR! code EBADPLATFORM
npm ERR! notsup Unsupported platform for @grpc-gen/[email protected]: wanted {"os":"win32,linux","arch":"any"} (current: {"os":"darwin","arch":"x64"})
I don't know the relationship of this download with the actual plugin I need to generate the JS I need from protobuf, but if this is the pre-compiled binary I need then my preference would be to just get this working on Linux and skip having to build protoc myself until the plugin binary is available on macOS. Maybe something @zaucy could chime in on?
For the first question, when compiling protoc manually, you can set the PREFIX environment variable to control where to install the result library.
For the 2nd question, unfortunately that package was not maintained by us here.
Posting here for reference because I liked this solution and maybe others will find this useful as well:
@juanjoDiaz created a Docker image that has all the protoc binaries baked in: https://github.com/grpc/grpc-web/issues/356#issuecomment-436735632
@natemurthy I made the package (@grpc-gen/protoc-gen-grpc-web) to help with the build ecosystem I am currently working with. This one is very out of date and I wouldn't recommend using it.
I do have a package called zaucy-protoc-gen-grpc-web that does have macos support (untested). This one is also out of date (around 2 months.) I intend to make a pull request (eventually) to facilitate a binary distribution on npm.
The source can be found here: https://github.com/zaucy/grpc-web/tree/zaucy-protoc-gen-grpc-web-package/packages/protoc-gen-grpc-web
The builds can be found here on vsts: https://zaucy.visualstudio.com/gRPC%20Web/_build?definitionId=4
I don't have a timeline when I will be able to get it up to date, but hopefully soon.
@zaucy @stanley-cheung Thanks guys. I'll go ahead and close this out. Is there a way I can track release progress on the pre-built plugin binaries?
Most helpful comment
Oh I see, you have the
protocbinary, but not the protoc library that we can link with-lprotoc.This is not good user experience, but you will have to manually compile and install the protoc library for now.
In the helloworld example README, here's the instructions on how to compile and install protoc:
We will be providing pre-compiled binaries for the
protoc-gen-grpc-webplugin across a few platforms shortly in the future.