bazel的helloworld

 

代码

tong@T17 ~/S/e/bazeltest> tree
.
├── main
│   ├── BUILD
│   └── main.cc
└── MODULE.bazel

2 directories, 3 files
tong@T17 ~/S/e/bazeltest> cat main/BUILD 
cc_binary (
        name = "hello",
        srcs = ["main.cc"],
)
tong@T17 ~/S/e/bazeltest> cat main/main.cc 

#include <iostream>


int main(int argc, char** argv) {
        std::cout << "hello hello" << std::endl;
        return 0;
}
tong@T17 ~/S/e/bazeltest> cat MODULE.bazel 
tong@T17 ~/S/e/bazeltest> 

 

编译

bazel clean --expunge
bazel build //main:hello

 

参考

https://github.com/bazelbuild/examples/tree/main/cpp-tutorial

https://docs.bazel.build/versions/0.23.0/tutorial/cpp.html

 

posted on 2025-05-13 10:15  toong  阅读(10)  评论(0)    收藏  举报