【发布时间】:2022-08-02 15:04:47
【问题描述】:
我试图在 C++ 中访问运行文件。我正在使用 Bazel 5.2.0。我试图这样访问:
std::string error;
std::unique_ptr<Runfiles> runfiles(Runfiles::Create(argv[0], &error));
if (!runfiles) {
std::cerr << error << std::endl;
return 1;
}
std::string path = runfiles->Rlocation(\"Test/Example.tx\");
std::cout << \"Example.tx: \" << path << std::endl;
std::ifstream in(path);
if (!in.is_open())
{
std::cout << \"Example.tx not found\" << std::endl;
return -1;
}
(Example.tx 是对的,只是懒得改) 该程序正在寻找一个路径,但该路径从 bazelisk 目录开始并且不指向二进制目录。
Example.tx: C:\\users\\nikla\\_bazel_nikla\\d47dtf2d\\execroot\\__main__\\bazel-out\\x64_windows-fastbuild\\bin\\Test\\Test.exe.runfiles/Test/Example.tx
Example.tx not found
结果我得到了这个。 也许有一种访问运行文件的新方法,但我没有找到它。
-
您介意发布您的 BUILD 文件吗?没有它来帮助您进行查询是一种挑战吗?
标签: bazel bazel-rules bazel-cpp