1
bazelでビルドコマンドを使用していくつかのヘッダーファイルを含めることができません。私はexampleに従いました。それらはbazelのドキュメントに含まれていました。bazelのcc_libraryルールによる外部ヘッダーファイルを正常に含めることができません
これは、以下の私のディレクトリの構造である私のビルドファイル
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",
],
)
です。
- WORKSPACE
-
- は
- ハローgreet.h
- hello-greet.cc
- hello-world.cc
- ビルドを含む主
- は
私はこれが役立つならば知っているが、ここではソースとヘッダファイルのためのいくつかのコードではありません。私はbazelのビルドコマンドを実行すると
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;
}
、それはあなたがすべき
INFO: Found 1 target...
ERROR: missing input file '//main:hello-greet.h'.