I want to use libtorch and gRPC library. libtorch also uses its own 
libprotobuf.a libprotobuf-lite.a libprotoc.a, which may have conflict with 
the corresponding protbuf library of grpc.

If I link only one among libtorch and grpc,  it works. However, If I tried 
to link both at the same time, build failed.

``` Error message



*/usr/bin/ld: CMakeFiles/server.dir/server.cc.o: in function 
`RunServer()':server.cc:(.text+0x139): undefined reference to 
`grpc::ServerBuilder::AddListeningPort(std::string const&, 
std::shared_ptr<grpc::ServerCredentials>, int*)'collect2: error: ld 
returned 1 exit statusmake[2]: *** [CMakeFiles/server.dir/build.make:150: 
server] Error 1*
```

```


*Environment: Ubuntu 20.04libtorch: 1.11.0+cpu gRPC: 1.50.0 ( And I tried 
1.40, 1.38) *
```


So I tried to install grpc with the protobuf library that libtorch uses. 
 The process as follows,
```


*# Install torch 1.11.0wget 
https://download.pytorch.org/libtorch/cpu/libtorch-shared-with-deps-1.11.0%2Bcpu.zipunzip
 
libtorch-shared-with-deps-1.11.0+cpu.zip && rm 
libtorch-shared-with-deps-1.11.0+cpu.zip*


















*# Install gRPCgit clone -b v1.50.0 https://github.com/grpc/grpccd grpcgit 
submodule update --initcd third_partyrm -r protobuf   # remove protobuf and 
clone protobuf version 3.13.0.1 that libtorch usesgit clone 
--recurse-submodules -b v3.13.0.1 --depth 1 --shallow-submodules 
https://github.com/protocolbuffers/protobuf.gitmkdir -p cmake/build && \    
    cd cmake/build && \        cmake -DgRPC_INSTALL=ON \              
-DgRPC_BUILD_TESTS=OFF \              
-DCMAKE_POSITION_INDEPENDENT_CODE=TRUE \              
-DCMAKE_INSTALL_PREFIX=/usr/local/grpc \              ../.. && \        
make && \        make install && \        ldconfig*
```
How can I resolve this problem??? Is it correct way to install protobuf 
that libtorch uses?

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/de8670f6-b6f6-4e69-bf60-9848e7c06d5fn%40googlegroups.com.

Reply via email to