Boyan Biandov <bbiandov@xxxxxxxxxxx> writes: > Excellent, this will explain the behavior. What is the default assumption > meaning what file extension would each compiler assume and also how would > one force the compiler to ignore the extension as a language descriptor and > interpret it as specified by the user (may be a command line parameter here) [snip] g++ always ignores file name extensions, and assumes C++ . gcc assumes .c is C, .cc, .cpp, .cxx, and .C are C++ . But gcc doesn't link in the standard C++ library, or C++ runtime, so it doesn't work for C++ The -x flag (see http://xrl.us/byzf) can be used to specify the langauge, overriding the above behaviors for *compilation*, but it doesn't change the linking behaviors. Just use 'gcc' for C, and 'g++' for C++ .