簡體   English   中英

如何在 CLion 中將外部 C++ 庫與 Bazel 一起使用?

[英]How can I use external C++ libraries with Bazel in CLion?

我正在編寫一個 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並索引它在那里找到的標頭?

這實際上是 bazel 0.28.0 中的一個錯誤,導致 CLion 在索引期間失敗。 我恢復到 0.27.2,問題就消失了。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM