0

I'm new to both FlatBuffers and Bazel. Can anyone post a minimal example for compiling flatc itself, the monster_generated.h file, and then sample_text.cpp?

When I run:

  • bazel build flatbuffers:flatc

I get the following error:

  • Unable to find package for @rules_cc//cc:defs.bzl: The repository '@rules_cc' could not be resolved.

I then build flatc with CMake temporarily, and moved on to building sample_text.cpp with Bazel. I thought I found a minimal example here:

However, when I run:

  • bazel build flatbuffers-bazel:sample_binary

I get:

  • fatal error: 'monster_generated.h' file not found

When I cheat and bring a copy of monster_generated.h (manually made with flatc, itself compiled with CMake) into the workspace, and add it to the srcs section of BUILD, I then get:

  • every rule of type cc_flatbuffers_compile implicitly depends upon the target '@flatbuffers//:flatc', but this target could not be found because of: no such package '@flatbuffers//': The repository '@flatbuffers' could not be resolved

This is probably a basic issue since it does appear that Bazel is supported, so any advice is very welcome!

Thanks,

Sean

Sean
  • 393
  • 2
  • 11

1 Answers1

0

You need to import rules_cc into your WORKSPACE in order to have it locally.

    http_archive(
        name = "rules_cc",
        urls = ["https://github.com/bazelbuild/rules_cc/archive/262ebec3c2296296526740db4aefce68c80de7fa.tar.gz"],
        strip_prefix = "rules_cc-262ebec3c2296296526740db4aefce68c80de7fa",
        sha256 = "3057c13fa4d431eb0e7a9c28eea13f25987d29f869406b5ee3f2bd9c4134cb0c",
    )
filippo
  • 146
  • 1
  • 7