【发布时间】:2017-07-06 20:54:21
【问题描述】:
我无法通过 bazel 中的构建命令包含一些头文件。我遵循了他们包含在 bazel 文档中的example。
这是我的构建文件
cc_library(
name = "hello-greet",
srcs = ["hello-greet.cc"],
hdrs = ["hello-greet.h"],
copts = ["-Imain/include"]
)
cc_binary(
name = "hello-world",
srcs = ["hello-world.cc"],
deps = [
":hello-greet",
],
)
下面是我的目录结构。
- 工作空间
- 主要
- 包括
- hello-greet.h
- hello-greet.cc
- hello-world.cc
- 构建
- 包括
我不知道这是否会有所帮助,但这里有一些源文件和头文件的代码。
hello-greet.cc
#include "hello-greet.h"
#include <string>
std::string get_greet(const std::string& who) {
return "Hello " + who;
}
你好世界.cc
#include "hello-greet.h"
#include <ctime>
#include <iostream>
#include <string>
void print_localtime() {
std::time_t result = std::time(nullptr);
std::cout << std::asctime(std::localtime(&result));
}
int main(int argc, char** argv) {
std::string who = "world";
if (argc > 1) {
who = argv[1];
}
print_localtime();
return 0;
}
当我运行 bazel build 命令时,它会报错
INFO: Found 1 target...
ERROR: missing input file '//main:hello-greet.h'.
【问题讨论】: