bazel项目在哪里存储其“.so”文件?

问题描述 投票:0回答:1

我有一个非常简单的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 function\n");
}
# cat hello-world.cc
#include<stdio.h>
#include"hello-greet.h"
int main(){
    f();
    printf("%s \n", "abc");
    return 0;
}

“bazel build hello-world && bazel run hello-world”将打印:

f function
abc

好的。但我找不到我的libhello-greet.so在哪里,它存放在哪里?我无法在当前目录下找到它。

非常感谢。

c++ build find shared bazel
1个回答
2
投票

Bazel将源树视为只读,并将其输出放在单独的输出目录中。找到这个目录的官方方法是运行bazel info output_base。但是,为了方便起见,Bazel还在工作区根目录中创建了一个名为bazel-out的目录的符号链接。

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

© www.soinside.com 2019 - 2024. All rights reserved.