Hi,
I tried to build gRPC with bazel and came across a linking error.
1) The following is a snippet from the BUILD I used.
cc_binary(
name = "grpc_cpp_plugin",
srcs = [
"src/compiler/cpp_plugin.cc",
],
linkopts=[
"-lprotoc -lprotobuf"
],
deps = [
":grpc_plugin_support",
],
)
2) libprotoc.a and libprotobuf.a have been installed in /usr/local/lib.
3) Target //:grpc_plugin_support has been build successfully.
4) Execute the build command "bazel build //:grpc_cpp_plugin --deleted_packages=third_party --subcommands" and I got the following error message:
...
>>>>> # //:grpc_cpp_plugin [action 'Linking grpc_cpp_plugin']
(cd /home/yinle/.cache/bazel/_bazel_yinle/efecb3aea10ca6e66c11c990034c4525/grpc-master && \
exec env - \
/usr/bin/gcc -o bazel-out/local_linux-fastbuild/bin/grpc_cpp_plugin -B/usr/bin/ -Wl,-z,relro,-z,now -no-canonical-prefixes -pass-exit-codes '-Wl,--build-id=md5' '-Wl,--hash-style=gnu' -Wl,-S -Wl,@bazel-out/local_linux-fastbuild/bin/grpc_cpp_plugin-2.params)
INFO: From Linking grpc_cpp_plugin:
/usr/bin/ld: cannot find -lprotoc
/usr/bin/ld: cannot find -lprotobuf
...
5) However, the command can be executed successfully if it is called in shell directly.
$ (cd /home/yinle/.cache/bazel/_bazel_yinle/efecb3aea10ca6e66c11c990034c4525/grpc-master && \
exec env - \
/usr/bin/gcc -o bazel-out/local_linux-fastbuild/bin/grpc_cpp_plugin -B/usr/bin/ -Wl,-z,relro,-z,now -no-canonical-prefixes -pass-exit-codes '-Wl,--build-id=md5' '-Wl,--hash-style=gnu' -Wl,-S -Wl,@bazel-out/local_linux-fastbuild/bin/grpc_cpp_plugin-2.params)
$ echo $?
0
Can someone give some help?
Thank you very much.
-Leo