ROS学习第一步掌握基本的Linux系统知识
###1,g++运行一个hello world程序
1.第一步安装编译器;在win系统下写一个程序需要接触到IDE环境,但是ubuntu中没有,只要写一个文本就可以,然后使用编译器编译成可执行文件就可以运行了。Ubuntu下也没有现成的像WIN系统下的文本编译器,我的选择是安装vim和gedit;
sudo apt-get install vim
sudo apt-get install gedit
2.创建helloworld.cpp文件
cd到自己想要的位置
touch helloworld.cpp
vim helloworld.cpp
输入:
#include <iostream>
using namespace std;
int main(int argc, char** argv)
{
cout<<"hello world"<<endl;
return 0;
}
3,使用g++编译器将helloworld.cpp文件编译成可执行文件
g++ helloworld.cpp
如果报错找不到命令,那就装一个编译器,我自己的ubuntu好像就自带有,不用装,如果没有就安装一下
sudo apt-get install g++
4.执行可执行文件
编译后会在同一目录下生成一个a.out可执行文件。在Linux系统下命令执行是“./”。
./a.out
hello world