我正在编写一个 C++ 程序,使用 CLion 作为我的 IDE,使用 Bazel 作为我的构建工具。我需要解析 XML 并想使用 xerces-c Apache 库。我已经设置了我的 WORKSPACE 文件来为 xerces-c 共享库创建一个本地存储库:
new_local_repository(
name = "system_libs",
path = "/usr/lib/x86_64-linux-gnu",
build_file_content = """
cc_library(
name = "xerces",
srcs = ["libxerces-c-3.2.so"],
visibility = ["//visibility:public"],
)
"""
)
但是,我无法说服 CLion(安装了 bazel 插件)索引 xerces-c 的头文件。
我试过:
工作空间:
new_local_repository(
name = "system_headers",
path = "/usr/local/include",
build_file_content = """
cc_library(
name = "xerces",
hdrs = glob(["xercesc/**/*.hpp"]),
visibility = ["//visibility:public"],
)
"""
)
BUILD:
cc_library(
name = "page_parser_lib",
srcs = ["page_parser.cc"],
hdrs = ["page_parser.h"],
deps = [
"@system_headers//:xerces",
"@system_libs//:xerces",
],
)
但这并没有帮助。
从命令行构建只需要 @system_libs//:xercesc
依赖项就可以正常工作。这似乎只是一个 CLion 索引问题。
问题:我如何说服 CLion 查看 /usr/local/include/xercesc
并索引它在那里找到的 header ?
最佳答案
这实际上是一个 bug在 bazel 0.28.0 中导致 CLion 在索引期间失败。我恢复到 0.27.2,问题消失了。
关于c++ - 如何在 CLion 中将外部 C++ 库与 Bazel 一起使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57066146/