bazel 项目将其".so"文件存储在哪里?

Where does bazel project store its ".so" files?

本文关键字:存储 在哪里 文件 so bazel 项目      更新时间:2023-10-16

我有一个非常简单的Bazel项目,该项目构建了图书馆和一个类似于下面的二进制文件:

cc_binary(
    name = "hello-world",
    srcs = ["hello-world.cc"],
    deps = [":hello-greet"],
)
cc_library(
    name = "hello-greet",
    srcs = ["hello-greet.cc"],
    hdrs = ["hello-greet.h"],
)

是的,它在我的Ubuntu框中工作:

# cat hello-greet.cc
#include<stdio.h>
void f(){
    printf("f functionn");
}
# cat hello-world.cc
#include<stdio.h>
#include"hello-greet.h"
int main(){
    f();
    printf("%s n", "abc");
    return 0;
}

" bazel build helly-world&amp; amp; amp; bazel run helly-world'将打印:

f function
abc

好吧,很好。但是我找不到我的libhello-greet在哪里,所以它存储在哪里?我在当前目录下找不到它。

非常感谢。

bazel将源树视为只读,并将其输出放在单独的输出目录中。找到此目录的官方方法是运行bazel info output_base。但是,为了方便起见,巴泽尔还与该目录中的该目录中的 bazel-out建立了符号链接。

在您的特定情况下,实际创建的hello-greet可能没有共享库,可以在不创建中间共享对象的情况下构建二进制文件。bazel build //:hello-greet应构建并显示hello-greet共享对象的路径。

它在 bazel build的输出中说的位置。通常在bazel-bin/...中,遵循与源文件相同的目录结构。