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

时间:2019-02-13 03:01:16

标签: c++ build find shared bazel

我有一个非常简单的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在哪里,在哪里存储?我在当前目录下找不到它。

非常感谢。

2 个答案:

答案 0 :(得分:2)

Bazel将源树视为只读,并将其输出放在单独的输出目录中。查找此目录的官方方法是运行bazel info output_base。但是,为方便起见,Bazel还在工作空间根目录中建立了指向此目录bazel-out的符号链接。

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

答案 1 :(得分:0)

它说明conda init的输出中。通常在System cannot find the path specified中,遵循与源文件相同的目录结构。

相关问题