无法通过 bazel 的规则成功包含外部头文件cc_library
Cannot successfully include external header file through cc_library rule for bazel
我无法通过 bazel 中的构建命令包含一些头文件。我遵循了它们包含在 bazel 文档中的示例。
这是我的构建文件
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.cc
- hello-world.cc
- 建
- 包括
我不知道这是否有帮助,但这里有一些源文件和头文件的代码。
hello-greet.cc
#include "hello-greet.h"
#include <string>
std::string get_greet(const std::string& who) {
return "Hello " + who;
}
hello-world.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 构建命令时,它抱怨此错误
INFO: Found 1 target...
ERROR: missing input file '//main:hello-greet.h'.
您应该能够通过向cc_library
添加includes = "."
来做您想做的事(不需要有copts
(
相关文章:
- 如何使用CMake编译.proto文件来生成.grpcp.pb.cc和.grpc.pb.h文件
- 编译要在英特尔Hyperscan中使用的.cc文件时出现问题
- 使用 g++ 编译时列出所有 cpp/cc 文件是否正常?
- 在头文件和 .cc 文件之间建立关系
- 如何在makefile中添加.c,.cc和.so文件以创建另一个.so
- 如何访问其他 .cc 文件中命名空间中定义的函数
- 如果需要测试,则C 将常数变量放在CC文件中
- 连接两个C 文件(list.cc and queue.cc)困难
- main.cc:5:30:致命错误:文件夹/file.h:没有这样的文件或目录
- 我如何确保修改.H文件时,使用Visual Studio 2008将包括其在内的.cc文件自动编译
- 我可以在生成文件中为 CC、CFLAGS 使用其他名称,或者将它们硬连接到 GNU make 中
- 如何在 Omnet++ INET 的示例中找到实现 .cc 文件
- .h文件应该是与外部函数的接口;如何在包含标头的.cc文件中进行定义
- 我可以在客户端使用 .cc 原型文件并在服务器端使用 .java proto 文件吗?
- 类成员C++标头和 .cc 文件问题
- 在头文件中声明要由 .cc 文件访问和填充的结构
- .cc和.cpp文件后缀有什么区别
- dsr/linkcache.cc:致命错误:list.h:没有这样的文件或目录
- 当项目导入到eclipse中时,.cpp文件被转换为.cc文件
- 把控制发回主站.Cc文件在我的c++项目从另一个源文件