I preparing for an examination a year, so paused the learning for a year, now I come back.
I write the blog on Ubuntu. I’m so lazy that I haven’t install Chinese Pinyin. That’s why I write it in English. If There are many mistakes please tell me, thanks.
切回Windows写中文
Write "HelloWorld"编写“HelloWorld”
In last blog I had finished build CyberRT, so I make a Hello World Demo.
在上一篇博客中,我完成了CyberRT框架的编译,所以我做了HelloWorld示例。
mkdir cyber/Demo_cc
Source Code源码
vim HelloWold.cc
#include "cyber/cyber.h"
int main(int argc, char *argv[])
{
apollo::cyber::Init(argv[0]);//初始化CyberRT框架
AINFO << "Hello World";//输出Hello World
return 0;
}
BUILD File BUILD文件
cc_binary(
name = "HelloWorld",
srcs = ["HelloWorld.cc"],
deps = ["//cyber"],
)
Build Command构建命令
bazel build cyber/demo_cc/...
Then I have built the program. And the binary file in
这样我就完成了构建程序。二进制文件存放在
/bazel-bin/cyber/demo_cc
Run运行
Before running, I have to change the setup.bash
在运行前,需要更改setup.bash
vim cyber/setup.bash
Find the
找到
export GLOG_alsologtostderr=0
Change it as
将它改为
export GLOG_alsologtostderr=1
This is used to display the message in terminate, if not do it, you can’t see anything on your terminate.
这是用于在终端中显示信息,如果没有做这一步,终端上不会有任何信息。
At last
最后
./bazel-bin/cyber/demo_cc/HelloWorld
Now you can see “Hello World” on your screen.
现在你可以在屏幕上看到“Hello World”