博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
linux下g++和gcc_Linux中gcc和g ++有什么区别?
阅读量:2531 次
发布时间:2019-05-11

本文共 1705 字,大约阅读时间需要 5 分钟。

linux下g++和gcc

gcc和g ++之间的区别 (Difference between gcc and g++)

Both are the compilers in Linux to compile and run C and C++ programs. Initially gcc was the GNU C Compiler but now a day's GCC (GNU Compiler Collections) provides many compilers, two are: gcc and g++.

两者都是Linux中用于编译和运行C和C ++程序编译器 。 最初, gcc是GNU C编译器,但如今,今天的GCC(GNU编译器集合)提供了许多编译器,其中两个是: gcc和g ++ 。

gcc is used to compile C program while g++ is used to compile C++ program. Since, a C program can also be compile complied through g++, because it is the extended or we can say advance compiler for C programming language.

gcc用于编译C程序,而g ++用于编译C ++程序。 因为,C程序也可以通过g ++编译,因为它是扩展的,或者可以说是C编程语言的高级编译器。

编译器命令通过gcc编译C程序 (Compiler command to compile C program through gcc)

gcc  program.c  -o binary

program.c is the C source file name and binary is the name of binary (object file) that will be executed.

program.c是C源文件的名称,binary是将要执行的二进制文件(目标文件)的名称。

通过g ++编译C ++程序的编译器命令 (Compiler command to compile C++ program through g++)

g++  program.cpp  -o binary

program.cpp is the C++ source file name and binary is the name of binary (object file) that will be executed.

program.cpp是C ++源文件的名称,binary是将要执行的二进制文件(目标文件)的名称。

C示例(main.c)-编译,通过gcc运行 (C Example (main.c) - Compile, Run through gcc)

/* main.c */ #include 
int main(){
printf("Hello, World!\n"); return 0;}

Output

输出量

sh-4.3$ gcc main.c -o main    sh-4.3$ ./main    Hello, World!

C ++示例(main.cpp)-编译,通过g ++运行 (C++ Example (main.cpp) - Compile, Run through g++)

/* main.cpp */ #include 
using namespace std; int main(){
cout << "Hello World" << endl; return 0;}

Output

输出量

sh-4.3$ g++ main.cpp -o main    sh-4.3$ ./main    Hello, World!

翻译自:

linux下g++和gcc

转载地址:http://jrxzd.baihongyu.com/

你可能感兴趣的文章
用74HC165读8个按键状态
查看>>
jpg转bmp(使用libjpeg)
查看>>
linear-gradient常用实现效果
查看>>
sql语言的一大类 DML 数据的操纵语言
查看>>
VMware黑屏解决方法
查看>>
JS中各种跳转解析
查看>>
JAVA 基础 / 第八课:面向对象 / JAVA类的方法与实例方法
查看>>
Ecust OJ
查看>>
P3384 【模板】树链剖分
查看>>
Thrift源码分析(二)-- 协议和编解码
查看>>
考勤系统之计算工作小时数
查看>>
4.1 分解条件式
查看>>
Equivalent Strings
查看>>
flume handler
查看>>
收藏其他博客园主写的代码,学习加自用。先表示感谢!!!
查看>>
H5 表单标签
查看>>
su 与 su - 区别
查看>>
C语言编程-9_4 字符统计
查看>>
在webconfig中写好连接后,在程序中如何调用?
查看>>
限制用户不能删除SharePoint列表中的条目(项目)
查看>>