交叉编译GRPC遇到的问题:
1._gRPC_CPP_PLUGIN-NOTFOUND: program not found or is not executable
不能直接开始编译,需要先编译编译机环境可执行的protoc和grpc-cpp-plugin
you will first need to build protoc
and grpc_cpp_plugin
for the host architecture. These tools are used during the build of gRPC, so we need copies of executables that can be run natively.
2.C++: Undefine reference to functions defined in absl::lts_
I believe the issue is that something like find_package(protobuf REQUIRED)
uses the embedded FindProtobuf
package from CMake:
FindProtobuf — CMake 3.28.0-rc2 Documentation
This package has not been updated to know about the Abseil
dependency. One needs to use:
find_package(protobuf REQUIRED CONFIG)
大致意思是find_package时使用的Findxxx.cmake不正确导致无法找到对应的静态库文件。配置成
find_package(protobuf CONFIG REQUIRED)问题完美解决。
教训:其实从官网clone下来的代码中BUILDING.md中写的很清楚,我们只需要按照步骤去执行一般不会出错。大部分错误都是我们自己一上来就按照自己下想法一通乱操作导致的。
例如在https://github.com/grpc/grpc/blob/master/BUILDING.md中有专门一段实例教我们怎么进行交叉编译: