`
fujinbing
  • 浏览: 234170 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

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.


分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics