我正在尝试在Mac M1上使用grpc,我遵循了以下指南:https://grpc.io/docs/languages/cpp/quickstart/
在我的项目CmakeLists.txt中,我有:
find_package(gRPC CONFIG REQUIRED)
当我尝试运行cmake时,我得到这个错误:
-- Could NOT find absl (missing: absl_DIR)
CMake Error at CMakeLists.txt:80 (find_package):
Found package configuration file:
/Users/venelin/.local/lib/cmake/grpc/gRPCConfig.cmake
but it set gRPC_FOUND to FALSE so package "gRPC" is considered to be NOT
FOUND. Reason given by package:
The following imported targets are referenced, but are missing: absl::base
absl::core_headers absl::memory absl::random_random absl::status absl::cord
absl::str_format absl::strings absl::synchronization absl::time
absl::optional absl::flat_hash_map absl::inlined_vector absl::bind_front
absl::hash absl::statusor absl::variant absl::utility protobuf::libprotobuf
protobuf::libprotoc
所以我决定这样做:
find_package(absl CONFIG REQUIRED)
find_package(gRPC CONFIG REQUIRED)
但我得到了这个错误
CMake Error at CMakeLists.txt:80 (find_package):
Could not find a package configuration file provided by "absl" with any of
the following names:
abslConfig.cmake
absl-config.cmake
Add the installation prefix of "absl" to CMAKE_PREFIX_PATH or set
"absl_DIR" to a directory containing one of the above files. If "absl"
provides a separate development package or SDK, be sure it has been
installed.
你知道我的错误在哪里吗?我怎么才能做到这一点?
2条答案
按热度按时间s1ag04yj1#
这看起来是一个OSX-M1特定的情况,最有可能通过真正遵循您获得的错误消息来解决:
将安装前缀“absl”添加到CMAKE_PREFIX_PATH
最有可能的是,你通过
brew install Abseil
安装了abs,它将它定位到/opt/homebrew/...
中。请注意,cmake还没有在那里查找,它习惯于在明显的Unix/Linux位置(如/usr/local
等)中查找内容。因此,找到
absl-config.cmake
(例如,浏览或最坏情况下使用find / -name absl-config.cmake
),并通过很可能是
此外,一般来说,您应该设置包含和链接目录
检查this post
wfypjpf42#
您不需要显式地将abseil添加到项目中。
在您的CMakeLists.txt中,您还必须包含
Protobuf
:确保在
CONFIG
模式下查找Protobuf
,因为它的查找模块不包括absl
,因此会导致很多麻烦。找理由?对
protobuf-config.cmake
和FindProtobuf.cmake
运行diff
,输出如下: