Skip to content
Branch: master
Find file History
pengwa and jin refine bazel-build/examples cpp-tutorial README files (#64)
* refine bazel-build/examples cpp-tutorial README files

* change external package reference format
Latest commit 64ffe9b Jun 19, 2018
Type Name Latest commit message Commit time
Failed to load latest commit information.
main Update (#35) Nov 23, 2017 refine bazel-build/examples cpp-tutorial README files (#64) Jun 20, 2018
WORKSPACE Update sample projects for Bazel tutorials. (#23) Jun 6, 2017

Stage 1

This showcases how to build a single file to create a runnable application.

This BUILD file shows that we want to build a C++ binary using the cc_binary rule provided by Bazel. In the cc_binary rule, name of the binary is specified in name attribute (in this example, it's hello-world), required source files to be built are provided in srcs attribute.

    name = "hello-world",
    srcs = [""],

To build this example you use (notice that 3 slashes are required in windows)

bazel build //main:hello-world

# In Windows, note the three slashes

bazel build ///main:hello-world

If the build is successful, Bazel prints the following output:

____Loading complete.  Analyzing...
____Found 1 target...
Target //main:hello-world up-to-date:
____Elapsed time: 0,400s, Critical Path: 0,01s

In the run log above you can see where the executable was built so you can locate it and use it.

You can’t perform that action at this time.