Linux下程序编写笔记


Linux下编写程序以后
分别用以下命令来编译和运行:
gcc c语言文件 -o 目标文件
如果要输出所有警告:gcc c语言文件 -Wall -o 目标文件;
./notec(notec即为目标文件)

C++
记事本写C++并用g++纊译     同样,启动记事本gedit
     写代码:
     #include<iostream>
     using namespace std;
     int main()
     {
       cout<<"Hi,learning c++ in g++"<<endl;

     return 0;
     }
     保存在主文件夹目录下,名字就叫noteplus.cpp
     启动终端,执行命令:
     [email=zhouxiongfei@Ubuntu:%7E$]zhouxiongfei@Ubuntu:~$[/email] g++ noteplus.cpp -o noteplus
     [email=zhouxiongfei@Ubuntu:%7E$]zhouxiongfei@Ubuntu:~$[/email] ./noteplus
     Hi,learning c++ in g++
     [email=zhouxiongfei@Ubuntu:%7E$]zhouxiongfei@Ubuntu:~$[/email]
提示,编译C++程序的三条命令
     g++ -Wall hellocpp.cpp
     gcc -Wall hellocpp.cpp -lstdc++
     gfortran -Wall hellocpp.cpp -lstdc++
     以上三条命令都是用来编译C++程序的。(假定源程序名为:hellocpp.cpp)

     选项 -Wall 开启编译器几乎所有常用的警告──强烈建议你始终使用该选项

相关内容