When building code example.cc

int main() { return 0; } 

by team

 $ gcc -o пример пример.cc && ./пример 

an error is displayed

undefined reference to '__gxx_personality_v0'

What could be the problem?

    2 answers 2

    Or rename the file as an пример.c . I remind you:

    1. C-files by default have the extension .c .
    2. C ++ - the default files have the extension .cc , .cp , .cxx , .cpp , .c++ , .C .

    Variants of such perversions as compilation of GCC, and then linking G ++, are omitted. Another way is to use the -x option of the compiler, which specifies the language to be used.

    • .c and .C are the same in my opinion. - gammaker
    • > .c and .c are the same in my opinion. Itself came across a C ++ code with such extension. (in unix, the register of file names matters) - Vladimir Gordeev
    • 2
      William von Hagen's The Definitive Guide to GCC says the following (my translation):> GCC compilers evaluate file name suffixes to determine the type of compiler used. Table 2-1 lists the suffixes related to g ++. >> Table 2-1 C ++ file name suffixes> .C - preprocessor processed C ++ code> .cc - preprocessor processed C ++ code (this is the standard extension for C ++ source code files)> .cpp - preprocessor processed C ++ code> .cxx - preprocessor-processed C ++ code> .ii - non-preprocessor C ++ code - northerner

    It is necessary so:

     $ g++ -o пример пример.cc && ./пример