gcc,g++ 编译的区别

test.cpp
int main()
{
return 1;
}

1.gcc 编译报错
gcc test.cpp
/tmp/ccgGC04E.o:(.eh_frame+0x12): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status

2.g++编译通过
g++ test.cpp

3.改扩展名(test.c)后gcc可以编译通过
gcc test.c

4.添加链接库(lstdc++)后,gcc可以编译通过

gcc -lstdc++ test.cpp


原因:
文件名:
file.c
C source code which must be preprocessed.
file.cpp
C++ source code which must be preprocessed. Note that in .cxx, the last two letters must both be literally x.
Likewise, .C refers to a literal capital C.


附录:

file.c
C source code which must be preprocessed.

file.i
C source code which should not be preprocessed.

file.ii
C++ source code which should not be preprocessed.

file.m
Objective-C source code. Note that you must link with the libobjc library to make an Objective-C program work.

file.mi
Objective-C source code which should not be preprocessed.

file.mm
file.M
Objective-C++ source code. Note that you must link with the libobjc library to make an Objective-C++ program work.
Note that .M refers to a literal capital M.

file.mii
Objective-C++ source code which should not be preprocessed.

file.h
C, C++, Objective-C or Objective-C++ header file to be turned into a precompiled header.

file.cc
file.cp
file.cxx
file.cpp
file.CPP
file.c++
file.C
C++ source code which must be preprocessed. Note that in .cxx, the last two letters must both be literally x.
Likewise, .C refers to a literal capital C.

file.mm
file.M
Objective-C++ source code which must be preprocessed.

file.mii
Objective-C++ source code which should not be preprocessed.

file.hh
file.H
file.hp
file.hxx
file.hpp
file.HPP
file.h++
file.tcc
C++ header file to be turned into a precompiled header.

file.f
file.for
file.ftn
Fixed form Fortran source code which should not be preprocessed.

file.F
file.FOR
file.fpp
file.FPP
file.FTN
Fixed form Fortran source code which must be preprocessed (with the traditional preprocessor).

file.f90
file.f95
file.f03
file.f08
Free form Fortran source code which should not be preprocessed.

file.F90
file.F95
file.F03
file.F08
Free form Fortran source code which must be preprocessed (with the traditional preprocessor).

file.ads
Ada source code file which contains a library unit declaration (a declaration of a package, subprogram, or generic,
or a generic instantiation), or a library unit renaming declaration (a package, generic, or subprogram renaming
declaration). Such files are also called specs.

file.adb
Ada source code file containing a library unit body (a subprogram or package body). Such files are also called
bodies.

file.s
Assembler code.

file.S
file.sx
Assembler code which must be preprocessed.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值